Daily Wallpaper – How to Get One Wallpaper for Each Day of the Week


So, I have an idea. To make me better aware of the day of the week, I want a custom wallpaper for each day. But I don't know how to accomplish that.

Does it exist any software that could do that for me?
If not, could anyone help with setting up a script that can change the background for each day?

Best Answer

Make a script as this example called dailywallpaper.sh:


# Variables explained:
# [wallpaperpath]....The directory with your wallpapers.
# [background].......The wallpaper. For the current "Week" day make a symbolic
#                    link to the desired image.  Name the line the a number 
#                    between 1-7 with a dash and the name without extension.
#                    (ie. ln -s image.png 3-daily for the thrird day of the
#                    week)
# [default]..........The default wallpaper to set if the file matching the
#                     current day isn't found.

DBUS=$(ps aux | egrep "/gnome-session/.*\s--session=" | awk '{print $2}')
export $(strings /proc/$DBUS/environ | egrep DBUS_SESSION_BUS_ADDRESS)
day=$(date +"%u")

# Default when the specified file isn't found.

[[ -f "$wallpaperpath$background" ]] && newwallpaper="$wallpaperpath$background"

gsettings set org.gnome.desktop.background picture-uri "file://${newwallpaper}"

The script usage is explained in the script's comments. You can set the script to run via crontab.

Crontab example entry:

# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
0 0 * * * /home/myaccount/bin/dailywallpaper.sh

The Startup Applications app is needed if you are not logged in at midnight. The startup app will make the change when you log in. You can find the Startup applications app in the Ubuntu Dash: (Ubuntu Dash -> Startup Applications).

The Startup Applications app

The crontab entry sets the background variable if you are logged in. The Startup Applications app sets the variable if you were not logged in at midnight when the cron ran.

Using the two, the correct day's wallpaper will always show.

Related Question