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
  • 1
    Possible duplicate of [Background not changing using gsettings from cron](http://askubuntu.com/questions/742870/background-not-changing-using-gsettings-from-cron) – David Foerster Jan 25 '17 at 01:57
  • 1
    `writing a script to mount a removable drive and then set the desktop background` You know, Linux and Unix philosophy is generally make an app do one thing and do it well. If you're writing a script to mount a drive - do that. It can run as root alright, and make setting wallpaper a separate script. – Sergiy Kolodyazhnyy Jan 25 '17 at 03:12

0 Answers0