3

So I got this script change_wallpaper, based from the answer from this: Automatically change Ubuntu wallpaper at a certain hour and ran it through cron.

# For changing wallpaper at a certain time
*/1 6,7,8,9,10,11,12,13,14,15,16,17 * * * /home/zero/.bin/change_wallpaper '/home/zero/Pictures/Wallpapers/dawn.jpg'
*/1 18,19,20,21,22,23,0,1,2,3,4,5 * * * /home/zero/.bin/change_wallpaper '/home/zero/Pictures/Wallpapers/dusk.jpg'

In summary, every time I start up my Ubuntu, it must change the wallpaper to dawn.jpg if it is morning, or dusk.jpg if it is evening.

change_wallpaper

#!/bin/bash -e
user=$(whoami)

fl=$(find /proc -maxdepth 2 -user "$user" -name environ -print -quit)
for i in {1..5}
do
  fl=$(find /proc -maxdepth 2 -user "$user" -name environ -newer "$fl" -print -quit)
done

export DBUS_SESSION_BUS_ADDRESS
DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS "$fl" | cut -d= -f2-)

IMG=$1
gsettings set org.gnome.desktop.background picture-uri "'file://${IMG}'"

One time, I noticed the cron script was not working anymore, so I tried manually running it. Then I noticed this error.

zero@zerosystem:~$ /home/zero/.bin/change_wallpaper /home/zero/Pictures/Wallpapers/dawn.jpg 

(process:5420): dconf-WARNING **: failed to commit changes to dconf: The given address is empty

Why is this? I also noticed that there's a different process number every time I run it, i.e. (process:5420).

  • Remove (Backup) your dconf-folder: mv ~/.config/dconf/ ~/.config/dconf.bak and try it again. – A.B. Feb 27 '16 at 12:32

1 Answers1

1

When doing gsettings, if the error message is

dconf-WARNING **: ...: failed to commit changes to dconf: The given address is empty

That probably mean that your env var DBUS_SESSION_BUS_ADDRESS is really empty, i.e it as been unset at some point.

I solved it with export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID/bus

Phi
  • 141