A timer/alarm clock and time-of-day wallpaper changer in BASH
This first one is a better version of my timer script with an alarm clock. It uses notify-send in order to give a popup, mktemp to create tempfiles, mpg123 to play an audible alarm, and zenity to create the snooze button. Instead of manually counting down the time in a terminal window, it uses the AT command to schedule a one-time task. Because that runs as root, I have to tell it to explicitly use the display for zenity - that's the
export DISPLAY=:0.0;you see in the code below.
This probably isn't the greatest code, but it's pretty straightforward. Copy, edit, see what happens and what works. That's how you learn! The code for the timer/alarm clock is available at this link as a bash script.
So what's the second script? It's to change my wallpaper hourly - based on the time of day. it uses feh (more on how to use feh is at the Arch Wiki, a two liner bash script calculator that uses the bc command (below), and sunrise.c, which has compiling directions in the code.
I renamed the files in the directory with day_, night_, or trans_ at the beginning of the filename (example: "day_coolbackground.jpg") to allow sorting. The beauty is, I can keep adding cool backgrounds to that directory without worries.
The two-line calculator script is this:
echo "scale=4; $1" | bc ; exit
but it's embedded in the file. You can find the bash script here. Just run it as an hourly crontab event, and work away!