17

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?

Sergey
  • 616

2 Answers2

29

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.

mfisch
  • 3,643
  • 2
    In Ubuntu 16.04, this solution does not persist across sessions, i.e. I log out of the user and log back in, the value I set has reverted. Personally I was trying to modify gsettings set org.gnome.desktop.session idle-delay 10. The only solution working for me is https://askubuntu.com/a/743024/358498 – tyleha Nov 30 '17 at 00:29
  • This will create a brand new dbus, which will unlikely result in any changes to the session (and its programs) listening on another dbus. – cdosborn May 17 '18 at 23:04
  • it works. I was trying to use gsettings set for keyboard layout in vagrant ssh script and it fails .But your suggestion solved the problem. Great trick. thanks a lot. – RedArrow Dec 19 '20 at 16:14
1

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

steeldriver
  • 136,215
  • 21
  • 243
  • 336