Govind Karmakar
Govind Karmakar

Reputation: 151

gsettings changes are not working over ssh

I am trying to set the idle timeout for Ubuntu 14.04 using gsettings from ssh.

The commands I am using are like this

dbus-launch gsettings set org.gnome.desktop.session idle-delay 600

dbus-launch gsettings set org.gnome.desktop.screensaver lock-delay 0

dbus-launch gsettings set org.gnome.desktop.screensaver lock-enabled true

dbus-launch gsettings set org.gnome.desktop.screensaver idle-activation-enabled true

After the commands are executed with various timeout periods the changes are taking place, but those timeout changes are getting lost after a reboot or logout.

Is this possible to make the timeout change persistent on reboot/logout.

Upvotes: 6

Views: 2877

Answers (2)

mejem
mejem

Reputation: 63

On Ubuntu 18.04 you have to set not only DBUS_SESSION_BUS_ADDRESS, but also XDG_RUNTIME_DIR. You can do so with this command (replace 121 with UID and gdm with user):

su gdm -s /bin/bash -c 'XDG_RUNTIME_DIR=/run/user/121 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/121/bus gsettings get org.gnome.desktop.session idle-delay'

Upvotes: 2

tyleha
tyleha

Reputation: 3429

Basically, when you are launching a new dbus instance with dbus-launch, you are saving the configurations to the wrong location by kicking off a new dbus. While adding dbus-launch to the beginning of the gsettings invokation will remove any error messages, you will not save changes.

There exists for the target user an existing dbus process, and via ssh your terminal doesn't receive the correct environment variables with which to address it.

The correct way to edit gsettings via ssh is to first identify the DBUS_SESSION_BUS_ADDRESS of the existing dbus process and set it as an environment variable. Thus:

PID=$(pgrep gnome-session)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ)
# And now:
gsettings set org.gnome.desktop.session idle-delay 600

Upvotes: 3

Related Questions