gsettings not working over ssh

I’m trying to change Unity Launcher icons on a remote computer with command:

gsettings set com.canonical.Unity.Launcher favorites ...

and it works perfectly

But when I do

ssh 127.0.0.1
gsettings set com.canonical.Unity.Launcher favorites ...

I get this:

    (process:9616): dconf-WARNING **: failed to commit changes to dconf: Error spawning 
command line `dbus-launch --autolaunch=aaa5bb6eaa7cd50f2af1f10000000004 --binary-syntax 
--close-stderr': Child process exited with code 1

And that is for any gsettings calls from ssh.
Where is the problem?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

I don’t think dbus is running in the remote ssh session. You need to start it yourself, but that’s pretty easy to do:

dbus-launch gsettings set com.canonical.Unity.Launcher favorites ...

Also make sure that the user is correct, you can set settings for another user (if that’s what you’re doing) like this:

sudo -u other dbus-launch gsettings set com.canonical.Unity.Launcher favorites ...

The above assumes the user you’re changing settings for is “other”, change as appropriate.

Solution 2

If there is a running dbus / X session belonging to the user, it may be sufficient to set the DISPLAY variable e.g.

$ gsettings set org.gnome.desktop.background picture-uri 'file:///usr/share/backgrounds/Winter_Morning_by_Shannon_Lucas.jpg'

** (process:28787): WARNING **: Command line `dbus-launch --autolaunch=ab102316d96f4621a2f3ccef0000000b --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n

** (process:28787): WARNING **: Command line `dbus-launch --autolaunch=ab102316d96f4621a2f3ccef0000000b --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n

but

$ DISPLAY=:1 gsettings set org.gnome.desktop.background picture-uri 'file:///usr/share/backgrounds/Winter_Morning_by_Shannon_Lucas.jpg'
$ 
$ DISPLAY=:1 gsettings get org.gnome.desktop.background picture-uri
'file:///usr/share/backgrounds/Winter_Morning_by_Shannon_Lucas.jpg'

Note that my display is :1 in this case – most often the primary desktop will be :0

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply