From cd3bba334b163304d11a53212d9f13d405e4ad29 Mon Sep 17 00:00:00 2001 From: DieGurke Date: Mon, 17 May 2021 20:17:56 +0200 Subject: [PATCH] Made user specific files created at runtime Removed corresponding files from PKGBUILD --- PKGBUILD | 8 ++++---- paperchanger.sh | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 410e413..e1d7d36 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -28,10 +28,10 @@ pkgver() { package() { cd ${pkgname} - rm -rf "${pkgdir}${HOME}/.${pkgname}" - mkdir -p "${pkgdir}${HOME}/.${pkgname}" - install -Dm755 paperchanger.conf.sh "${pkgdir}/etc/paperchanger.conf.sh" - install -Dm755 current_wallpaper.txt "${pkgdir}${HOME}/.${pkgname}/current_wallpaper.txt" +# rm -rf "${pkgdir}${HOME}/.${pkgname}" +# mkdir -p "${pkgdir}${HOME}/.${pkgname}" +# install -Dm755 paperchanger.conf.sh "${pkgdir}/etc/paperchanger.conf.sh" +# install -Dm755 current_wallpaper.txt "${pkgdir}${HOME}/.${pkgname}/current_wallpaper.txt" install -Dm644 README.md "${pkgdir}/usr/share/doc/${pkgname}/README.md" install -Dm755 paperchanger.sh "${pkgdir}/usr/bin/paperchanger" } diff --git a/paperchanger.sh b/paperchanger.sh index b78afb5..85205e6 100755 --- a/paperchanger.sh +++ b/paperchanger.sh @@ -2,9 +2,21 @@ # Simple CLI to make wallpaper changes with xwallpaper more comfortable -read -r current_file_path < $HOME/.paperchanger/current_wallpaper.txt +mkdir -p $HOME/.paperchanger -source /etc/paperchanger.conf.sh +if [[ ! -f "$HOME/.paperchanger/current_wallpaper.txt" ]]; then + touch $HOME/.paperchanger/current_wallpaper.txt +fi + + +if [[ ! -f "$HOME/.paperchanger/paperchanger.conf.sh" ]]; then + echo '# This is the configuration file used by the paperchanger program + +default_directory=' > $HOME/.paperchanger/paperchanger.conf.sh +fi + +read -r current_file_path < $HOME/.paperchanger/current_wallpaper.txt +source $HOME/.paperchanger/paperchanger.conf.sh function _help() { echo "" @@ -33,7 +45,7 @@ function _set() { } function _change_config_path() { - sed -i "s/^default_directory=.*\$/default_directory=${1//\//\\/}/" /etc/paperchanger.conf.sh + sed -i "s/^default_directory=.*\$/default_directory=${1//\//\\/}/" $HOME/.paperchanger/paperchanger.conf.sh } case "$#" in