When Daniel over at Red Sweater posted about FlexTime the other day, I immediately thought about automating something for the code for 50 minutes - break for 10 minutes thing I always read about on productivity sites but have never tried. Of course, he already thought of that and included a sample routine for this purpose.
I decided that it might be neat to have it run an AppleScript that would essentially toggle between two environments: coding and break time. I wasn't sure how useful it would be, but I've never written any AppleScript and thought it might be worthwhile, at least for that.
Quick & Dirty
-----------------
The setup has two AppleScripts: start-break and start-coding, two todo text files: break.todo and coding.todo, two Automator apps: break.todo.app and coding.todo.app and of course the FlexTime routine.
Let's start with the start-coding AppleScript:
say "time to start coding"
tell application "Adium"
set my status type to away
set my status message to "coding"
end tell
tell application "System Events"
(*hide Adium*)
set this_app to some item of (get processes whose name = "Adium")
set visible of this_app to false
(*hide NetNewsWire*)
set this_app to some item of (get processes whose name = "NetNewsWire")
set visible of this_app to false
(*show Terminal*)
set this_app to some item of (get processes whose name = "Terminal")
set visible of this_app to true
(*show Camino*)
set this_app to some item of (get processes whose name = "Camino")
set visible of this_app to true
(*show Eclipse*)
set this_app to some item of (get processes whose name = "java")
set visible of this_app to true
end tell
(*execute automator app that opens coding.todo file in TextMate*)
tell application "coding.todo.markdown"
activate
end tell
Again, I've never written any AppleScript so I sort of just threw this together. I assume there are ways to ensure the application you are trying to toggle visibility is actually running that would safe guard this script from dying a horrible death, but that wasn't really the point of this.