Tuesday 2 February 2010

A handy delay script for startup applications


Typically applications that have been told to start on login by the user such as Firestarter or Conky may need to be delayed slightly in order to ensure they load properly, and without interference from other processes. A simple script comes to the rescue.

Howto after the jump:



To create the script:

gedit delay.sh
Copy and paste the following into the file:

#!/bin/bash

if [ $# == 2 ] ; then

sleep $1
nohup $2 &

else

echo "Usage: $0 delay command"

fi
exit


Save and quit.

Make the script executable:
chmod 700 delay.sh 
When used in startup applications the command should be
/home/username/delay.sh ?? command
Where ?? is the number of seconds you would like the command delayed.

For instance:
/home/username/delay.sh 15 "conky"
Would delay the startup of conky by 15 seconds.

Hope you find it useful!

3 comments: