gsettings changes are not working over ssh
Asked Answered
M

2

6

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.

Mcclung answered 15/5, 2015 at 9:37 Comment(0)
B
3

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
Berniecebernier answered 1/12, 2017 at 22:16 Comment(0)
P
2

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'
Psych answered 3/10, 2019 at 15:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.