1

I'm working on a script to set some particular gsettings. If the script is being executed as user its working as expected. But, because of some reason I need my script to work with sudo.

One solution i found was to use sudo -u <username> -H ./script to run it in user space. It is getting executed without any error, but my changes are not taking place in the user space.

I unable to understand what am I missing here. When i run sudo -u <currentUser> -H bach -c `echo " $USER $UID"` it is working as expected and giving the user values.

What might be the issue here?

Thanks in advance!

1 Answers1

1

the reason is you are not using dbus-launch infront of gsettings command.

see man dbus-launch

if you run sudo -Hu user gsettings set org.gnome.desktop.background picture-uri '' you will get error

administrator@pratap:~/Music$ sudo -Hu user gsettings set org.gnome.desktop.background picture-uri ''

(process:11889): dconf-WARNING **: 18:54:53.409: failed to commit changes to dconf: Error spawning command line “dbus-launch --autolaunch=454398a8b6e94accb53d9b7e5361faaa --binary-syntax --close-stderr”: Child process exited with code 1
administrator@pratap:~/Music$

enter image description here

enter image description here

enter image description here

enter image description here