/kernel_reloaded/

Author:

Novi članci

Flickr Goodness

Categories

August 7, 2007 @ 15:19

Script for GUI Linux Job Scheduling

       

If you need to start some gnu/linux app under console then great at command comes to the rescue, and it is easy to use.
But if you have a need to start some GUI app under KDE or Gnome than just issuing at command can’t do it by itself.

I wanted to have some apps start on my desktop before I come to work and sit at the desk. I also close some apps at 16:15h as I work until 16h.
Closing apps is easy because I just used gnome-schedule which is a frontend to cron with command "pkill firefox" to shutdown firefox at given time.

Starting apps is a bit more tricky because all cron scripts are run under root privileges and I need an app to start under regular desktop user privileges.

With some help from fedora-list mailinglist I got this script:

================== cut ===============
#!/bin/bash
#
# A script to create a script to run GAIM at 8:15 am.
#
script_file=~/start-gaim.sh

if [ -z $XAUTHORITY ] ; then
echo XAUTHORITY in not set!
exit 1
fi

if [ -z $DISPLAY ] ; then
echo DISPLAY is not set!
exit 1
fi

echo \#\!/bin/bash > $script_file
echo export XAUTHORITY=$XAUTHORITY >> $script_file
echo export DISPLAY=$DISPLAY >> $script_file
echo gaim >> $script_file
chmod +x $script_file

at -f $script_file 8:15 am

================== cut ===============

The only drawback is that I need to start this script every day under my username in order to have gaim start the next morning at 8:15am.
Do you have some idea how to make this work automatically every day? Do you have some other ideas how to do this in some other way? Please post your ideas as comments.

Filed under english, linux

6 Comments »

  1. Posted by mark0

    August 7, 2007 @ 23:39

    su -c ’skripta’ pero ?

  2. Posted by Rohit Jain

    August 9, 2007 @ 14:04

    kewl…. this is surely a cool script… thanks

  3. Posted by Joe

    November 14, 2007 @ 23:01

    I’m not too familiar with the at command, but I think that if you don’t want to rerun that script every day, putting this line into your ~/start-gaim.sh script should work:

    at -f 8:16 am

    this will resubmit your above script at 8:16, with 23:59 to go until starting gaim again.

  4. Posted by wwp

    January 2, 2008 @ 17:52

    You could use your user’s crontab for this (`crontab -e` to edit crontab’ed jobs, `crontab -l` to list them), and even to start gaim.

  5. Posted by valent

    January 11, 2008 @ 17:51

    crontab doesn’t start gui apps :(

    I wrote crontab entry for pidgin and it doesn’t work:

    $ crontab -l
    50 * * * * pidgin

    it was 17:48 so I tested if it will start at 17:50 and it didn’t.

  6. Posted by vlada

    January 21, 2008 @ 13:47

    Just cron that shell script instead, should work

RSS feed for comments on this post

Leave a Comment

    Recent Comments

    • valent: Download Helper extension for dowloading flash videos: http://sandbox.downloadhelper. net/index.php
    • Valent: * Clean up unwanted banners and surrounding “fluff,” especially prior to printing a page * See...
    • valent: I leave it enabled for longer and longer periods of time… I used to disable it right away on FC6 but...
    • Kevin Kofler: Even before disabling SELinux? ;-) Or are you one of those folks leaving it enabled?
    • Syam Krishnan: 1. Boot in rescue mode, rip grub boot image to dual boot using NTLoader 2. Install RPMFusion, vlc,...

    Archives


    ·

    Meta

    del.icio.us

    Visit my Mugshot page