xfdesktop in a cron job

Guido Berhoerster gber at opensuse.org
Fri Nov 25 01:33:56 CET 2011


Hi,

* houghi <houghi at houghi.org> [2011-11-24 23:11]:
> I am running openSUSE 12.1 and I am running a script in cron that I used
> to run in 11.4 as well without any problem. Also the cronjob is identical.
> 
> However what used to work in 11.4 does not work in 12.1. My best guess
> would be here.
> 
> The script can be found here http://houghi.org/script/background It
> basically changes the background to a one of my several thousand
> wallpapers in several hundred directries at random. When I run the script
> in a terminal I have no problems.
> 
> However when I want to lauch it in a cron job, I get the folloing error:
> Failed to parse arguments: Cannot open display
> 
> Crontab has the following line:
> * * * * *   /usr/local/bin/background
> 
> The problem is cause by the following line:
> export DISPLAY=:0.0 && xfdesktop --reload 
> 
> Even when I use the following I get the same error:
> * * * * *  export DISPLAY=:0.0 && /usr/bin/xfdesktop --reload
> 
> As far as I can tell I must use the export part to get it working.

your approach is broken, there is no clean, reliable way to get
access to your users display from cron. Instead I'd suggest you
just convert your little script into a small daemon which can be
started by the session. In its main loop you can let it change
the background reliably and then sleep for the desired amount of
time.
-- 
Guido Berhoerster


More information about the Xfce mailing list