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)

please Help me! thanks

  • 2
    What are you hoping to gain from running that command as root? – doug Nov 20 '17 at 23:26
  • No .this command just run as otheruser. – hamid Nov 20 '17 at 23:29
  • Nobody knows??? – hamid Nov 21 '17 at 15:47

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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.