Last active
December 17, 2018 22:16
-
-
Save jb-1980/13a3f14f11ab7aa5750a944d37aa8976 to your computer and use it in GitHub Desktop.
Dynamic wallpaper directories for Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# NAME: season.sh | |
# PATH: ~/bin | |
# DATE: December 15, 2018 | |
# NOTE: modified from script given at: https://askubuntu.com/questions/1100934/change-dynamic-wallpaper-directory-every-season/1102084#1102084 | |
# User defined variables, change to suit your needs | |
# Our directory names, lines indented for cosmetic reasons only | |
SlideShowDir=$HOME/wallpapers/slideshow | |
SpringDir=$HOME/wallpapers/spring | |
SummerDir=$HOME/wallpapers/summer | |
FallDir=$HOME/wallpapers/fall | |
WinterDir=$HOME/wallpapers/winter | |
# Day of year that seasons start | |
Spring=$(date --date="March 21" '+%j') | |
Summer=$(date --date="June 21" '+%j') | |
Fall=$(date --date="Sep 21" '+%j') | |
Winter=$(date --date="Dec 21" '+%j') | |
# Start of Mainline | |
DOY=$(date '+%j') # DOY = Current Day of Year | |
# Reference: https://stackoverflow.com/questions/10112453/how-to-get-day-of-the-year-in-shell | |
# For days less than 100, the date function returns as 0XX, which is interpreted as an octal. | |
# This will force it to be a decimal and avoid the "value too great for base" error. | |
# Reference: https://stackoverflow.com/questions/12821715/convert-string-into-integer-in-bash-script | |
DOY=$((10#$DOY)) | |
Spring=$((10#$Spring)) | |
Summer=$((10#$Summer)) | |
Fall=$((10#$Fall)) | |
Winter=$((10#$Winter)) | |
# Reference: https://stackoverflow.com/questions/12614011/using-case-for-a-range-of-numbers-in-bash | |
if ((DOY>="$Spring" && DOY<"$Summer")) ; then | |
ln -sfn "$SpringDir" "$SlideShowDir" # Spring has sprung! | |
elif ((DOY>="$Summer" && DOY<"$Fall")) ; then | |
ln -sfn "$SummerDir" "$SlideShowDir" # Hit the beach! | |
elif ((DOY>="$Fall" && DOY<"$Winter")) ; then | |
ln -sfn "$FallDir" "$SlideShowDir" # Rake those leaves! | |
else | |
ln -sfn "$WinterDir" "$SlideShowDir" # Shovel the snow! | |
fi | |
exit 0 # Command not necessary but good habit to signify no Abend. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment