diff --git a/00-Splash.png b/00-Splash.png new file mode 100644 index 0000000..53c7b76 Binary files /dev/null and b/00-Splash.png differ diff --git a/01-Morning.png b/01-Morning.png new file mode 100644 index 0000000..2fa640a Binary files /dev/null and b/01-Morning.png differ diff --git a/02-Late-Morning.png b/02-Late-Morning.png new file mode 100644 index 0000000..afb6425 Binary files /dev/null and b/02-Late-Morning.png differ diff --git a/03-Afternoon.png b/03-Afternoon.png new file mode 100644 index 0000000..b4011d7 Binary files /dev/null and b/03-Afternoon.png differ diff --git a/04-Late-Afternoon.png b/04-Late-Afternoon.png new file mode 100644 index 0000000..05c247d Binary files /dev/null and b/04-Late-Afternoon.png differ diff --git a/05-Evening.png b/05-Evening.png new file mode 100644 index 0000000..343356d Binary files /dev/null and b/05-Evening.png differ diff --git a/06-Late-Evening.png b/06-Late-Evening.png new file mode 100644 index 0000000..799cfcb Binary files /dev/null and b/06-Late-Evening.png differ diff --git a/07-Night.png b/07-Night.png new file mode 100644 index 0000000..3f60553 Binary files /dev/null and b/07-Night.png differ diff --git a/08-Late-Night.png b/08-Late-Night.png new file mode 100644 index 0000000..b855a77 Binary files /dev/null and b/08-Late-Night.png differ diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..dff3b7a --- /dev/null +++ b/install.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +pwd=`pwd` + +sep="--------------------------------------------------------------------------" +echo $sep +echo "*** 8bit Day Wallpaper Rotator for Linux ***" +echo "*** Rotator Script: http://www.reddit.com/u/javajames64 ***" +echo "*** Auto Installer: http://www.reddit.com/u/OhMrBigshot ***" +echo $sep +echo + + +echo "* Changing permissions... [1/2]" +chmod +x update.sh +echo + +echo "* Creating cron jobs... [2/2]" +echo + +read -p "Create a cron job every hour? [y/n] " yn +case $yn in + [Yy]*) + line="0 * * * * ${pwd}/update.sh" + if ! crontab -l | grep -Fxq "$line"; then + (crontab -l ; echo "$line") | crontab - + else + echo "[cron already exists, skipping]" + fi + ;; +esac +echo + +read -p "Create a cron job after each reboot? [y/n] " yn +case $yn in + [Yy]*) + line="@reboot ${pwd}/update.sh" + if ! crontab -l | grep -Fxq "$line"; then + (crontab -l ; echo "$line") | crontab - + else + echo "[cron already exists, skipping]" + fi + ;; +esac +echo + +read -p "Run script after system resume (from suspension)? (requires root) [y/n] " yn +case $yn in + [Yy]*) + sudo -k sh -c "echo -e \"case \"\${1}\" in\n\tresume|thaw)\n\t\t${pwd}/update.sh\n\t;;\nesac\" > /etc/pm/sleep.d/RotatingWallpaper.sh" + if [ $? -ne 0 ]; then + echo " --> ERROR: Return from suspension script not created"; + else + sudo sh -c "chmod +x /etc/pm/sleep.d/RotatingWallpaper.sh" + sudo sh -c "chown $USER /etc/pm/sleep.d/RotatingWallpaper.sh" + fi + ;; +esac +echo + + +echo "Done!" diff --git a/uninstall.sh b/uninstall.sh new file mode 100755 index 0000000..8303403 --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +pwd=`pwd` + +sep="--------------------------------------------------------------------------" +echo $sep +echo "*** 8bit Day Wallpaper Rotator for Linux ***" +echo $sep +echo + + +echo "This will revert all the changes." +echo + +read -p "Are you sure that's what you want? [y/n] " yn +case $yn in + [Yy]* ) + echo + echo "Removing tasks..." + + line="${pwd}/update.sh" + crontab -l | grep -v "$line1" | crontab - + + if [ -f /etc/pm/sleep.d/RotatingWallpaper.sh ]; then + echo "We need root permissions to delete '/etc/pm/sleep.d/RotatingWallpaper.sh': " + sudo -k sh -c "rm /etc/pm/sleep.d/RotatingWallpaper.sh" + fi + ;; +esac +echo + +read -p "Delete this directory and its files? [y/n] " yn +case $yn in + [Yy]* ) + echo "rm -R $pwd" + ;; +esac +echo + + +echo "Done! We're sorry to see you go!" diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..1bbf8c2 --- /dev/null +++ b/update.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +sessionfile=`find "${HOME}/.dbus/session-bus/" -type f` +export `grep "DBUS_SESSION_BUS_ADDRESS" "${sessionfile}" | sed '/^#/d'` + +files=( + 01-Morning.png + 02-Late-Morning.png + 03-Afternoon.png + 04-Late-Afternoon.png + 05-Evening.png + 06-Late-Evening.png + 07-Night.png + 08-Late-Night.png +) + +#Timings for the backgrounds in order. Your life may vary. +timing=( + 7 + 10 + 12 + 17 + 18 + 19 + 21 + 23 +) + +hour=`date +%H` + +case $XDG_CURRENT_DESKTOP in + Mint|Mate) setcmd="gsettings set org.mate.background picture-uri";; + Cinnamon) setcmd="gsettings set org.cinnamon.background picture-uri";; + *) setcmd="feh --bg-fill";; +esac +if [[ -z $XDG_CURRENT_DESKTOP ]]; then + case $DESKTOP_SESSION in + i3) setcmd="feh --bg-fill" + esac +fi + +for i in {7..0..-1} +do + if [[ $hour -ge ${timing[i]} ]]; then + $setcmd file://$DIR/${files[i]} + echo "Wallpaper set to ${files[i]}" + exit + fi +done + +$setcmd file://$DIR/${files[7]} +echo "Wallpaper set to ${files[7]}"