0

I'm writing a script to mount a removable drive and then set the desktop background to a file on that drive. The script needs to run as root in order to use cryptsetup and mount. But when the script runs as root, I can't get gsettings to work to set the desktop background.

If I just write gsettings set org.gnome.desktop.background picture-uri file:///path/to/image.jpg in the script, meaning that gsettings is also run as root, nothing at all happens.

If instead I write sudo -u username gsettings set org.gnome.desktop.background picture-uri file:///path/to/image.jpg, so that gsettings is run as username, the script fails with the following error:

(process:#####): dconf-CRITICAL **: unable to create file '/home/username/.cache/dconf/username': Permission denied.  dconf will not work properly.

So how can I get gsettings to work from a script run as root?

ryanw
  • 667
  • 5
  • 22

0 Answers0