1

The following works in cron:

* *  * * *  non-root-user  export DISPLAY=:0.0; zenity --info

And displays a zenity dialog on non-root-user's desktop each minute.

But if I do the following:

* *  * * *  root  export DISPLAY=:0.0; zenity --info

it does not work - nothing is shown on 0.0 display. What am I doing wrong?

1
  • Does not worked for me. 3.5.0-17-generic
    – user25165
    Jan 8, 2014 at 4:26

1 Answer 1

2

You have run afoul of X-windows security! See man Xsecurity, man xauth, and man xhost, but in the short term, you can allow any UID running on your local system to have access to your X display by doing:

xhost +localhost  

as your non-root UID from the session that has the display.

2
  • It would be resetted after reboot?
    – Rogach
    Feb 7, 2012 at 18:36
  • 1
    It would be reset by xhost -localhost or by exiting the X session that owns the $DISPLAY. Fixing things by a reboot is usually not necessary, and often doesn't work. It's not the Linux way.
    – waltinator
    Feb 7, 2012 at 20:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .