Skip to content

gsettings needs DBUS_SESSION_BUS_ADDRESS of current user #73

Description

@monte-monte

In order to make changes with gsettings or dconf you shoul have "DBUS_SESSION_BUS_ADDRESS" variable of current user. Since scripts are called from root they don't have any dbus session address, and variable in gsettings can't be changed.

You can read about this here: http://stackoverflow.com/questions/10374520/gsettings-with-cron/10390963#10390963 or here: www.unix.com/shell-programming-scripting/203631-dbus_session_bus_address-script-called-crontab.html for example.

I used this lines in my hooks:

PID=$(pgrep -u $LOGNAME gnome-session)  # instead of 'gnome-session' it can be also used 'nautilus' or 'compiz' or the name of a process of a graphical program about that you are sure that is running after you log in the X session
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions