Schedule iChat Status with Cron
My mac at work is left on all the time, and I kept forgetting to log in and out of iChat at the start and end of the day. I wanted to continue using iChat for it's simplicity, OS integration and stability, so I looked into how to schedule iChat to go online at the start of each weekday and offline again at the end.
Luckily this is pretty easy on OSX thanks to the power of Applescript and the good old-fashioned cron scheduler.
The first step is to fire up Applescript Editor from Applications > Utilities and make two scripts. Applescript is pretty readable and self explanatory:
tell application "iChat" set the status to available end tell
Save this to your home folder as iChat_available.scpt
tell application "iChat" set the status to offline end tell
Save this to your home folder as iChat_offline.scpt
Now to test that they work, open Terminal and type
osascript ~/iChat_offline.scpt
...which should take you offline.
Now you need to add this to cron by running:
crontab -e
and adding the following lines:
30 8 * * 1-5 osascript ~/iChat_available.scpt 30 17 * * 1-5 osascript ~/iChat_offline.scpt
This will put you in vi, so to edit the file press i to get in insert mode, type or paste the lines, then press Esc to get out of insert mode, followed by :x (colon then x), then Enter to save and close the file.
These cron directives will set iChat to available at 30 minutes past 8, every day of every month on days 1 to 5 of the week, then offline on the same days at five thirty. If you want, you could add lines to take you offline or 'away' over lunch. Or annoy your friends by going online and offline every five minutes over the weekend.
No feedback yet
Leave a comment
| « 2011 | ASCII game 1 » |