gsettings not working over ssh [duplicate]
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?
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