Although the suggestion below is far from "waterproof", it offers at least some "first-line" precautions against changing the wallpaper too easily.
You could make a small script to run in the background that checks every x seconds if the current wallpaper is still the wallpaper that you set in the first place.
The command to see (get) what is the current wallpaper:
gsettings get org.gnome.desktop.background picture-uri
If you run this in a terminal, you will get an output looking like:
'file:///home/jacob/Thema/Bureaublad4/Frog.jpg'
We can make the script restore the original wallpaper if it has changed.
To set a specific wallpaper, the command is:
gsettings set org.gnome.desktop.background picture-uri 'file:///home/jacob/Thema/Bureaublad4/Frog.jpg'
If we use these two in a python script, we could get the following (python3, 14.04):
#!/usr/bin/env python3
import time
import subprocess
set_wallpaper = "file:///home/jacob/Thema/Bureaublad4/Frog.jpg"
cmd2 = "gsettings set org.gnome.desktop.background picture-uri "+set_wallpaper
cmd1 = "gsettings get org.gnome.desktop.background picture-uri"
def check_wall():
curr_wallpaper = subprocess.check_output(["/bin/bash", "-c", cmd1]).decode("utf-8").strip()
if curr_wallpaper == "'"+set_wallpaper+"'":
pass
else:
subprocess.Popen(["/bin/bash", "-c", cmd2])
while True:
check_wall()
time.sleep(10)
The only difference for 12.04 is the shebang: 12.04 does not come with python3 by default, so the shebang should be:
#!/usr/bin/env python
How to use
copy the script into an empty file. Change the wallpaper line (after set_wallpaper =
) into the path to your wallpaper image (starting with file://
, like in the example). Save it as something.py
.
run it by the command:
python3 /path/to/something.py
or (12.04)
python /path/to/something.py
If all works as you wish, add it to your startup applications: Dash > "Startup Applications" > "Add"