Using xdotool with crontab

1,552 views
Skip to first unread message

bro

unread,
Feb 26, 2012, 1:39:01 AM2/26/12
to xdotool-users
can't seem to get this to work with crontab


#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/
games


WID=`/usr/bin/xdotool search --name "firefox" | head -1`
/usr/bin/xdotool windowactivate $WID
/usr/bin/xdotool key F5


sleep 3


WID=`/usr/bin/xdotool search --name "firefox" | head -1`
/usr/bin/xdotool windowactivate $WID
/usr/bin/xdotool key F5



I've tried everything I could think of and what I could find around
the net.

I'm trying to make a display using html that runs all the time, I want
to use the f5 key so that I can make displays of various times, so I
don't have to enable autoreload in firefox.

My next step is to just write a long script that starts at boot and
starts another one that starts the first. I don't like giving up...

It works manually of course, but no luck with crontab -e.

Jordan Sissel

unread,
Feb 27, 2012, 7:04:57 PM2/27/12
to thefre...@hotmail.com, xdotool-users
In your crontab, the environment is slightly different. Most X applications (xdotool included) look for a DISPLAY environment variable.

You might find things start working if you set DISPLAY=:0 in your crontab. :)

-Jordan

Anthony Thyssen

unread,
Feb 28, 2012, 1:49:08 AM2/28/12
to xdotoo...@googlegroups.com, thefre...@hotmail.com

The crontab has 'minimal' environment.

It will not have the DISPLAY or XAUTHORITY environment set, and as such
would not have access to the X server.

You generally need as a minimum...
DISPLAY=0 and the users HOME

However that only works if the authorization is located in
".Xauthority" of the uses home.

If it isn't then a XAUTHORITY environment variable is needed to specify
the file location of the authorization 'cookies'.

For details see the manpage "xauth"

Alternative to 'xauth' access controlis to use xhost to allow any
localhost connection. However some clients hate this and 'turns off'
xhost access regardless of is the user wanted it or not. TCL and WISH
scripts is well known for this big-brother type of action.

See "xhost" manpage, also look at "Xsecurity"


Note xhost access is not recommended as it allows ANY user on the
localhost to connect to the display, not just the logged in 'owner'.
That however may be preferable for a system controlled 'kiosk' type
machine, where no actual user actually 'logs in' on the display.

For more information in access to X window Displays see my OLD
document...
http://www.ict.griffith.edu.au/anthony/info/X/Display.needs


Anthony Thyssen ( System Programmer ) <A.Th...@griffith.edu.au>
--------------------------------------------------------------------------
A priestly young person called Eric,
Whilst practising to be a cleric,
Misspelt his god's name,
'twas really a shame,
And thus ended Eric, the cleric.
--------------------------------------------------------------------------
Anthony's Castle http://www.ict.griffith.edu.au/anthony/

bro

unread,
Feb 28, 2012, 3:43:53 PM2/28/12
to xdotool-users
I added

DISPLAY=:0

to the script and crontab.


It's working someplace now, I put

WID=`/usr/bin/xdotool search --name "firefox" | head -1`
/usr/bin/xdotool windowactivate $WID
/usr/bin/xdotool key F5

In a couple of different scripts so I need to narrow it down to what
is working.

Thanks
Reply all
Reply to author
Forward
0 new messages