Dock Indicator / Asynchronous Scripting

Nov 28, 2008 03:02

I just had a little "ah-ha!" moment I'd like to share.

I'm always looking for new and lazier ways to do user interaction that don't involve display dialog or third party software. My brilliant idea today is to use the launch app command to unobtrusively start a stay-open script app that contains a reopen handler which quits itself. Pseudocode:

Script app 1:
on idle: if itunes is shuffling then launch app 2
on reopen: tell itunes to shuffle, launch app 2

Script app 2:
on reopen: tell itunes to stop shuffling, tell me to quit

The point of this is if iTunes is shuffling, app 2 will magically appear in my dock. Clicking app 1's dock icon will also cause this to happen. If app 2's icon is visible, I can click it to dismiss the indication and reset iTunes' shuffle state. I like the idea because it lets me cue up a bit of code in such a way that I don't have to deal with it right now to keep the app 1 idler happy. In the past I found use for this behavior with asynchronous scripts in shell. App 2 could even be written to fetch a property from app 1 without app 1 having to explicitly pass it as a parameter.
Previous post Next post
Up