Early in the morning, as soon as I go to work I don't have problems to remember to log on to Adium. But most of the times I tend to forget to log out of it before I leave at the end of the day. So, I thought of making it automatic through some script. Since my OS is Mac OS X I thought it would be better if I used AppleScript. So started my foray on to it.
My script looks like below to start and quit application Adium. You can pretty much start and stop any application like this by replacing Adium with it's name.
Script to start the application
tell application "Adium" activate end tell
Script to stop the application
tell application "Adium" quit end tell
I don't think there is any need to explain the script as it is self explanatory. This is a very trivial script. You can do crazy stuff with this AppleScript. Just google for it and you find tonnes of pages.
As you can see it doesn't tell anything about the time it's going to start and stop Adium. Good catch! The trick is to use iCal for this purpose. Create a new event and under alarm options choose "run script". It let's you choose your saved above script. In the event you can specify at what time everyday it should start. For example, I set up two recurring events on week days. First event starts at 9AM and runs the first script. I named the script as start_adium. The second event runs at 5PM and runs the second script through alarm settings which I named it as stop_adium.
That's it. Now it's automated to start and stop Adium on every week day. Cool. Ha! But there are disadvantages to it too. Even if you are not on time to the office script gets run exactly at the specified time. Which means people think that you are there in the office. Again I don't care about this and it works for me. I'm sure there must be ways to write a script to make it start and stop as soon as you unlock and lock the screens. I guess no one forgets to lock the screen if he is a system admin. Right? Since I have this idea right now I'll try to look into this and let you know if I find something.
Note: Use shortcut "Command + Space bar" to initiate Spotlight and type applescript. As you type you would see AppleScript Editor next to applications. Hit enter and you see an AppleScript editor to write your script. Just for start, you can copy my script on it and run it to see what happens. Use some other application name in the place of Adium if you don't have it on your system. Hope this helps someone.
No comments:
Post a Comment