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?

  • Possible to do. I can write a custom script that does the job. What are your requirements ? Have folder with 7 images numbered 1 through 7 ? Or maybe read everything from a configuration file ? Please explain more – Sergiy Kolodyazhnyy Oct 11 '16 at 22:48

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.

  • Crontab doesn't deal with GUI unless you add $DISPLAY variable to the command. Not the best way to do it – Sergiy Kolodyazhnyy Oct 11 '16 at 23:54
  • Thanks. I was in the process of testing the script. Thanks for the quick validation! Still debugging procedure. The example was something to get the OP started. – L. D. James Oct 12 '16 at 0:00
  • Good. Let me know if you want me to do additional tuning,testing and/or checks. I'm still waiting for OP's requirements , so will also be writing an answer, but I can help with yours too once I get back home – Sergiy Kolodyazhnyy Oct 12 '16 at 0:12
  • Hi @Serg setting the wallpaper (editing gsettings) does not require $DISPLAY, what you would expect, but the DBUS_SESSION_BUS_ADDRESS -variable. – Jacob Vlijm Oct 12 '16 at 7:42
  • Yes, that's what it does require . . .My mistake. Typically if it's a GUI app, you do need $DISPLAY variable, but gsettings isn't really a GUI app. Confused myself there – Sergiy Kolodyazhnyy Oct 12 '16 at 7:45

I would use cycling wallpaper:

enter image description here

Then I would use conky to display the day of the week:

enter image description here

From this web site: https://ubuntuforums.org/showthread.php?t=281865&page=2325&p=13554728#post13554728

And this picture: https://ubuntuforums.org/attachment.php?attachmentid=264010

It's very easy to have Conky to dislay MONDAY in big capital letters. Check out the website and find an eye pleasing script and change it to suit your needs.


Setting wallpaper from cron

Setting wallpaper from cron requires setting gsettings. Since cron runs with a very limited set of environment variables, you will need set a special variable, called:


Not the (what you would expect) DISPLAY -variable.
See also here how to do that.


Alternatively, you can use the simple script below. On startup, the script sets the corresponding wallpaper, then all the script does is wait until midnight, to change the wallpaper. Then again sleep until the next midnight and so on.

The script

import time
import os
import subprocess

picsdir = "/home/jacob/Bureaublad/pics"
images = sorted([os.path.join(picsdir, pic) for pic in os.listdir(picsdir)])

def calc_sleep():
    secdata = time.strftime("%H %M %S").split()
    seconds = (int(secdata[0])*3600)+(int(secdata[1])*60)+(int(secdata[2]))
    # calculate the sleep time until next midnight
    return 86400+1-seconds

while True:
    # weekday
    day = int(time.strftime("%w"))
    # the corresponding image from the set folder
    image = images[day-1]
    # set the image from gsettings
    command = ["gsettings", "set", "org.gnome.desktop.background",
               "picture-uri", "file://"+image]
    # calculate the time to sleep until next midnight
    wait = calc_sleep()

How to use

  1. Create a directory with seven wallpapers
  2. Copy the script into an empty file, save it as wallswitch.py
  3. In the head of the script, set the path to the wallpapers
  4. Test-run the script:

    python3 /path/to/wallswitch.py

    The wallpaper, corresponding to the day of the week should be set.

  5. If all works fine, add it to Startup Applications: Dash > Startup Applications > Add. Add the command:

    /bin/bash -c "sleep 10 && python3 /path/to/wallswitch.py"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.