Mission Completed....
cited from UbuntuForums: henriquemaia
crontab: How to run GUI programs with cron
See Original Link
http://ubuntuforums.org/archive/index.php/t-185993.html
-----------------------------------------------------------------------------------------------------------
This is an updated Thread from 5.10. It works on 6.06.
First of all, please refer to this howto (
http://ubuntuforums.org/showthread.php? ... light=cron) to learn more about crontab.
My motivation to find this out was because there are several radio shows I really like and I was always missing them. As such, I needed something to make amarok play the chosen radio station at specific times. Probably this could be achieved through a more elegant solution, but what is explained here works great. Also, I knew that by learning how to do this, I could use it for many other things.
To accomplish this, you have to edit your crontab:
crontab -eyou can also use a nicer GUI tool to edit crontab, like gnome-schedule or KCron (both available on the repositories).
If you use a GUI tool, please adapt the instructions accordingly. I will explain this using as basis the default crontab editor.
To run a GUI command on cron, you'll have to tell cron what display the program should use. For that you use:
export DISPLAY=:0 The ':0' is the default. If you like the program to run on other display, please change the number accordingly (e.g. :1, :2, etc).
So, you add to what is explained here (
http://ubuntuforums.org/showthread.php? ... light=cron):
01 04 * * * /usr/bin/somedirectory/somecommandthe export variable, like this:
01 04 * * * export DISPLAY=:0 && /usr/bin/somedirectory/somecommandYou can omit the full path to the application bin. For amarok, you just need to use the 'amarok' command. Works fine both ways.
So, in my case, as I want amarok to play Antena2 (Portuguese classical radio station) at a specific time, I use:
30 16 * * 7 export DISPLAY=:0 && amarok mms://rdp.oninet.pt/antena2 This will make amarok start the Antena2 url every Sunday, at 16:30. But I want also to shut up amarok after the show is finished. So, I use:
0 17 * * 7 export DISPLAY=:0 && amarok -s
This will shut up amarok at 17:00 every Sunday.
(Just a side note - to make amarok play mms urls, you have to set it to use xine engine)
You can use this export trick to the limits of your imagination with every kind of application you want.
Another example that occurs to me is when you neet to use an application for a certain period of time, from 3AM to 9AM, for exemple.
0 3 * * * export DISPLAY=:0 && your_favorite_applicationthat will start your_favorite_application (change this to the command that runs the application you desire) everyday at 3AM. To shut it down, I use:
0 9 * * * killall your_favorite_applicationThis will shut it down at 9AM.
Hope this helps some of you.
If you have more ideas how to use this trick (or how to improve this HowTo), please share with us in this thread.