when use "gsettings set org.gnome.desktop.background picture-uri file_path" from root not working

I when use gsettings set org.gnome.desktop.background picture-uri file_path from root not working but run from Anotheruser it`s work.

Even when I put it inside crontab -u Anotheruser -e. But not working

My os : ubuntu 16.04 LTS

I tried all the way but it did not.

Example :

su - USER -c "command"
# or ways sudo and su
crontab -u USER -e
DISPLAY=:1 ...
DISPLAY=:0 ...
DISPLAY=:0.0 ...
dbus-launch ...
PID=$(pgrep gnome-session)
export DBUS_SESSION_BUS_ADDRESS= ...

please Help me! thanks

3

1 Answer

I found the solution :

export DBUS_SESSION_BUS_ADDRESS=$(pgrep -a dbus-daemon -U USERNAME | grep -o 'unix:abstract.*$')
gsettings set org.gnome.desktop.background picture-uri FILE_ADDRESS

AND into crontab :

@reboot su USERNAME -c 'export DBUS_SESSION_BUS_ADDRESS=$(pgrep -a dbus-daemon -U USERNAME | grep -o "unix:abstract.*$");export DISPLAY=:0;gsettings set org.gnome.desktop.background picture-uri FILE_ADDRESS'

just replace USERNAME by your user AND replace FILE_ADDRESS by your picture Address

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like