Search code examples
shellsudognome

How to apply dconf and gnome-shell settings to all users


I am trying to write a script that install some Gnome extensions and change some settings.

My script runs under sudo.

I am tring to do those sample changes for all users.

_USERS="$(eval getent passwd {$(awk '/^UID_MIN/ {print $2}' /etc/login.defs)..$(awk '/^UID_MAX/ {print $2}' /etc/login.defs)} | cut -d: -f1)" 

for u in $_USERS
do

    sudo -u ${u} gnome-shell-extension-tool -e [email protected]

    sudo -u ${u} dconf write /org/gnome/nautilus/preferences/executable-text-activation "'ask'"

end

This thing never works at all. What to do?


Solution

  • I have found the solution on internet. I need to add bussession before command. Like,

    sudo -u ${_USERS} DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${RUSER_UID}/bus" commandhere