diff --git a/install-gnome-backgrounds.sh b/install-gnome-backgrounds.sh index c15c54d..cab92b0 100755 --- a/install-gnome-backgrounds.sh +++ b/install-gnome-backgrounds.sh @@ -4,8 +4,14 @@ readonly ROOT_UID=0 readonly MAX_DELAY=20 # max delay for user to enter root password REPO_DIR="$(cd "$(dirname "$0")" && pwd)" -BACKGROUND_DIR="/usr/share/backgrounds" -PROPERTIES_DIR="/usr/share/gnome-background-properties" + +if [[ "$UID" -eq "$ROOT_UID" ]]; then + BACKGROUND_DIR="/usr/share/backgrounds" + PROPERTIES_DIR="/usr/share/gnome-background-properties" +else + BACKGROUND_DIR="$HOME/.local/share/backgrounds" + PROPERTIES_DIR="$HOME/.local/share/gnome-background-properties" +fi THEME_VARIANTS=('WhiteSur' 'Monterey' 'Ventura' 'Sonoma') SCREEN_VARIANTS=('1080p' '2k' '4k') @@ -72,6 +78,9 @@ install() { cp -a --no-preserve=ownership ${REPO_DIR}/xml-files/timed-xml-files/${theme}-timed.xml ${BACKGROUND_DIR}/${theme} cp -a --no-preserve=ownership ${REPO_DIR}/xml-files/gnome-background-properties/${theme}.xml ${PROPERTIES_DIR} + + sed -i "s/@BACKGROUNDDIR@/$(printf '%s\n' "${BACKGROUND_DIR}" | sed 's/[\/&]/\\&/g')/g" "${BACKGROUND_DIR}/${theme}/${theme}-timed.xml" + sed -i "s/@BACKGROUNDDIR@/$(printf '%s\n' "${BACKGROUND_DIR}" | sed 's/[\/&]/\\&/g')/g" "${PROPERTIES_DIR}/${theme}.xml" } uninstall() { @@ -195,13 +204,6 @@ uninstall_wallpaper() { echo } -if [[ $UID -ne $ROOT_UID ]]; then - echo - prompt -e "ERROR: Need root access! please run this script with sudo." - echo - exit 1 -fi - if [[ "${uninstall}" != 'true' ]]; then install_wallpaper && install_nord_wallpaper else diff --git a/xml-files/gnome-background-properties/Mojave-nord.xml b/xml-files/gnome-background-properties/Mojave-nord.xml index df114d9..da80ab5 100644 --- a/xml-files/gnome-background-properties/Mojave-nord.xml +++ b/xml-files/gnome-background-properties/Mojave-nord.xml @@ -3,8 +3,8 @@ Mojave Nord Background - /usr/share/backgrounds/Wallpaper-nord/Mojave-nord-light.png - /usr/share/backgrounds/Wallpaper-nord/Mojave-nord-dark.png + @BACKGROUNDDIR@/Wallpaper-nord/Mojave-nord-light.png + @BACKGROUNDDIR@/Wallpaper-nord/Mojave-nord-dark.png zoom solid #3071AE diff --git a/xml-files/gnome-background-properties/Monterey.xml b/xml-files/gnome-background-properties/Monterey.xml index 6416c9c..596bf95 100644 --- a/xml-files/gnome-background-properties/Monterey.xml +++ b/xml-files/gnome-background-properties/Monterey.xml @@ -3,8 +3,8 @@ Monterey Background - /usr/share/backgrounds/Monterey/Monterey-light.jpg - /usr/share/backgrounds/Monterey/Monterey.jpg + @BACKGROUNDDIR@/Monterey/Monterey-light.jpg + @BACKGROUNDDIR@/Monterey/Monterey.jpg zoom solid #51a2da @@ -13,7 +13,7 @@ Monterey Time of Day - /usr/share/backgrounds/Monterey/Monterey-timed.xml + @BACKGROUNDDIR@/Monterey/Monterey-timed.xml zoom solid #ffffff diff --git a/xml-files/gnome-background-properties/Sonoma.xml b/xml-files/gnome-background-properties/Sonoma.xml index 0b0e29c..ce0dc7f 100644 --- a/xml-files/gnome-background-properties/Sonoma.xml +++ b/xml-files/gnome-background-properties/Sonoma.xml @@ -3,8 +3,8 @@ Sonoma Background - /usr/share/backgrounds/Sonoma/Sonoma-light.jpg - /usr/share/backgrounds/Sonoma/Sonoma-dark.jpg + @BACKGROUNDDIR@/Sonoma/Sonoma-light.jpg + @BACKGROUNDDIR@/Sonoma/Sonoma-dark.jpg zoom solid #51a2da @@ -13,7 +13,7 @@ Sonoma Time of Day - /usr/share/backgrounds/Sonoma/Sonoma-timed.xml + @BACKGROUNDDIR@/Sonoma/Sonoma-timed.xml zoom solid #ffffff diff --git a/xml-files/gnome-background-properties/Ventura.xml b/xml-files/gnome-background-properties/Ventura.xml index f4d4280..91df238 100644 --- a/xml-files/gnome-background-properties/Ventura.xml +++ b/xml-files/gnome-background-properties/Ventura.xml @@ -3,8 +3,8 @@ Ventura Background - /usr/share/backgrounds/Ventura/Ventura-light.jpg - /usr/share/backgrounds/Ventura/Ventura-dark.jpg + @BACKGROUNDDIR@/Ventura/Ventura-light.jpg + @BACKGROUNDDIR@/Ventura/Ventura-dark.jpg zoom solid #51a2da @@ -13,7 +13,7 @@ Ventura Time of Day - /usr/share/backgrounds/Ventura/Ventura-timed.xml + @BACKGROUNDDIR@/Ventura/Ventura-timed.xml zoom solid #ffffff diff --git a/xml-files/gnome-background-properties/WhiteSur.xml b/xml-files/gnome-background-properties/WhiteSur.xml index d2b6d46..7bc8475 100644 --- a/xml-files/gnome-background-properties/WhiteSur.xml +++ b/xml-files/gnome-background-properties/WhiteSur.xml @@ -3,8 +3,8 @@ WhiteSur Background - /usr/share/backgrounds/WhiteSur/WhiteSur-light.jpg - /usr/share/backgrounds/WhiteSur/WhiteSur.jpg + @BACKGROUNDDIR@/WhiteSur/WhiteSur-light.jpg + @BACKGROUNDDIR@/WhiteSur/WhiteSur.jpg zoom solid #51a2da @@ -13,8 +13,8 @@ WhiteSur Nord Background - /usr/share/backgrounds/Wallpaper-nord/WhiteSur-nord-light.png - /usr/share/backgrounds/Wallpaper-nord/WhiteSur-nord-dark.png + @BACKGROUNDDIR@/Wallpaper-nord/WhiteSur-nord-light.png + @BACKGROUNDDIR@/Wallpaper-nord/WhiteSur-nord-dark.png zoom solid #6882b3 @@ -23,7 +23,7 @@ WhiteSur Time of Day - /usr/share/backgrounds/WhiteSur/WhiteSur-timed.xml + @BACKGROUNDDIR@/WhiteSur/WhiteSur-timed.xml zoom solid #ffffff diff --git a/xml-files/timed-xml-files/Monterey-timed.xml b/xml-files/timed-xml-files/Monterey-timed.xml index d4bda94..ca03ad8 100644 --- a/xml-files/timed-xml-files/Monterey-timed.xml +++ b/xml-files/timed-xml-files/Monterey-timed.xml @@ -13,39 +13,39 @@ 3600.0 -/usr/share/backgrounds/Monterey/Monterey-morning.jpg +@BACKGROUNDDIR@/Monterey/Monterey-morning.jpg 18000.0 -/usr/share/backgrounds/Monterey/Monterey-morning.jpg -/usr/share/backgrounds/Monterey/Monterey-light.jpg +@BACKGROUNDDIR@/Monterey/Monterey-morning.jpg +@BACKGROUNDDIR@/Monterey/Monterey-light.jpg 18000.0 -/usr/share/backgrounds/Monterey/Monterey-light.jpg +@BACKGROUNDDIR@/Monterey/Monterey-light.jpg 21600.0 -/usr/share/backgrounds/Monterey/Monterey-light.jpg -/usr/share/backgrounds/Monterey/Monterey.jpg +@BACKGROUNDDIR@/Monterey/Monterey-light.jpg +@BACKGROUNDDIR@/Monterey/Monterey.jpg 18000.0 -/usr/share/backgrounds/Monterey/Monterey.jpg +@BACKGROUNDDIR@/Monterey/Monterey.jpg 7200.0 -/usr/share/backgrounds/Monterey/Monterey.jpg -/usr/share/backgrounds/Monterey/Monterey-morning.jpg +@BACKGROUNDDIR@/Monterey/Monterey.jpg +@BACKGROUNDDIR@/Monterey/Monterey-morning.jpg diff --git a/xml-files/timed-xml-files/Sonoma-timed.xml b/xml-files/timed-xml-files/Sonoma-timed.xml index e195d91..3f39baf 100644 --- a/xml-files/timed-xml-files/Sonoma-timed.xml +++ b/xml-files/timed-xml-files/Sonoma-timed.xml @@ -13,39 +13,39 @@ 3600.0 -/usr/share/backgrounds/Sonoma/Sonoma-light.jpg +@BACKGROUNDDIR@/Sonoma/Sonoma-light.jpg 18000.0 -/usr/share/backgrounds/Sonoma/Sonoma-light.jpg -/usr/share/backgrounds/Sonoma/Sonoma-light.jpg +@BACKGROUNDDIR@/Sonoma/Sonoma-light.jpg +@BACKGROUNDDIR@/Sonoma/Sonoma-light.jpg 18000.0 -/usr/share/backgrounds/Sonoma/Sonoma-light.jpg +@BACKGROUNDDIR@/Sonoma/Sonoma-light.jpg 21600.0 -/usr/share/backgrounds/Sonoma/Sonoma-light.jpg -/usr/share/backgrounds/Sonoma/Sonoma-dark.jpg +@BACKGROUNDDIR@/Sonoma/Sonoma-light.jpg +@BACKGROUNDDIR@/Sonoma/Sonoma-dark.jpg 18000.0 -/usr/share/backgrounds/Sonoma/Sonoma-dark.jpg +@BACKGROUNDDIR@/Sonoma/Sonoma-dark.jpg 7200.0 -/usr/share/backgrounds/Sonoma/Sonoma-dark.jpg -/usr/share/backgrounds/Sonoma/Sonoma-light.jpg +@BACKGROUNDDIR@/Sonoma/Sonoma-dark.jpg +@BACKGROUNDDIR@/Sonoma/Sonoma-light.jpg diff --git a/xml-files/timed-xml-files/Ventura-timed.xml b/xml-files/timed-xml-files/Ventura-timed.xml index af6cef3..54c82d8 100644 --- a/xml-files/timed-xml-files/Ventura-timed.xml +++ b/xml-files/timed-xml-files/Ventura-timed.xml @@ -13,39 +13,39 @@ 3600.0 -/usr/share/backgrounds/Ventura/Ventura-light.jpg +@BACKGROUNDDIR@/Ventura/Ventura-light.jpg 18000.0 -/usr/share/backgrounds/Ventura/Ventura-light.jpg -/usr/share/backgrounds/Ventura/Ventura-light.jpg +@BACKGROUNDDIR@/Ventura/Ventura-light.jpg +@BACKGROUNDDIR@/Ventura/Ventura-light.jpg 18000.0 -/usr/share/backgrounds/Ventura/Ventura-light.jpg +@BACKGROUNDDIR@/Ventura/Ventura-light.jpg 21600.0 -/usr/share/backgrounds/Ventura/Ventura-light.jpg -/usr/share/backgrounds/Ventura/Ventura-dark.jpg +@BACKGROUNDDIR@/Ventura/Ventura-light.jpg +@BACKGROUNDDIR@/Ventura/Ventura-dark.jpg 18000.0 -/usr/share/backgrounds/Ventura/Ventura-dark.jpg +@BACKGROUNDDIR@/Ventura/Ventura-dark.jpg 7200.0 -/usr/share/backgrounds/Ventura/Ventura-dark.jpg -/usr/share/backgrounds/Ventura/Ventura-light.jpg +@BACKGROUNDDIR@/Ventura/Ventura-dark.jpg +@BACKGROUNDDIR@/Ventura/Ventura-light.jpg diff --git a/xml-files/timed-xml-files/WhiteSur-timed.xml b/xml-files/timed-xml-files/WhiteSur-timed.xml index 807c1f6..835fb05 100644 --- a/xml-files/timed-xml-files/WhiteSur-timed.xml +++ b/xml-files/timed-xml-files/WhiteSur-timed.xml @@ -13,39 +13,39 @@ 3600.0 -/usr/share/backgrounds/WhiteSur/WhiteSur-morning.jpg +@BACKGROUNDDIR@/WhiteSur/WhiteSur-morning.jpg 18000.0 -/usr/share/backgrounds/WhiteSur/WhiteSur-morning.jpg -/usr/share/backgrounds/WhiteSur/WhiteSur-light.jpg +@BACKGROUNDDIR@/WhiteSur/WhiteSur-morning.jpg +@BACKGROUNDDIR@/WhiteSur/WhiteSur-light.jpg 18000.0 -/usr/share/backgrounds/WhiteSur/WhiteSur-light.jpg +@BACKGROUNDDIR@/WhiteSur/WhiteSur-light.jpg 21600.0 -/usr/share/backgrounds/WhiteSur/WhiteSur-light.jpg -/usr/share/backgrounds/WhiteSur/WhiteSur.jpg +@BACKGROUNDDIR@/WhiteSur/WhiteSur-light.jpg +@BACKGROUNDDIR@/WhiteSur/WhiteSur.jpg 18000.0 -/usr/share/backgrounds/WhiteSur/WhiteSur.jpg +@BACKGROUNDDIR@/WhiteSur/WhiteSur.jpg 7200.0 -/usr/share/backgrounds/WhiteSur/WhiteSur.jpg -/usr/share/backgrounds/WhiteSur/WhiteSur-morning.jpg +@BACKGROUNDDIR@/WhiteSur/WhiteSur.jpg +@BACKGROUNDDIR@/WhiteSur/WhiteSur-morning.jpg