Checking whether a script can open a display?
William O'Higgins
william.ohiggins-H217xnMUJC0sA/PxXw9srA at public.gmane.org
Tue Mar 1 23:30:30 UTC 2005
On Tue, Mar 01, 2005 at 05:36:31PM -0500, William Park wrote:
>On Tue, Mar 01, 2005 at 05:03:04PM -0500, Lennart Sorensen wrote:
>> On Tue, Mar 01, 2005 at 04:52:29PM -0500, William O'Higgins wrote:
>> > I use a cron job to update the backdrop (root window) of my window
>> > manager. Sometimes I am not running X, however, and then my mail box
>> > fills up with cron telling me that it cannot open display :0.0. Is
>> > there a way I can test whether I can open that display so I can quit
>> > cleanly?
>> > Any pointers would be appreciated. Thanks.
>>
>> if [ -z "$DISPLAY" ]; then
>> echo "No display";
>> else
>> echo "Do something";
>> fi
>
>Hmm... Checking DISPLAY works if you're in Xterm shell session, say
>from ~/.profile. But, I don't think Cron sees or care about DISPLAY
>environment variable. In fact, Cron by design runs with minimum set of
>environment variables.
>
>Try 'ps -C X' or something.
This is, indeed, the problem - cron runs with a very limited
$ENVIRONMENT. If not for that I'm sure that it would work.
>By the way, why would Cron cause reboot of your computer if X is not
>running?
I think you misunderstand - I have no idea what causes the reboots, but
I am pretty sure it isn't cron. X is running when I leave the house,
but after a reboot, it isn't (because I have not run startx). The fact
that X is not running is the clue that the machine rebooted (I would not
necessarily notice otherwise - I am not a slave to "uptime").
--
yours,
William
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://gtalug.org/pipermail/legacy/attachments/20050301/3a7d91a0/attachment.sig>
More information about the Legacy
mailing list