How can I automatically launch an application whenever the Mac goes idle?
Is there a way to launch an application, such as Transmission, every time the computer goes idle (instead of sleeping)?
This is a very hard feat to accomplish, primarily because there is no specific definition of "Idle". The only programs I've seen to actually have idle features are Instant Messaging Clients and the recent Mac App Store releases of Growl. And those simply have a configurable time that goes off after the set number of minutes when there's no mouse/keyboard activity occurring.
There's been similar discussion on the Macworld Forums some years ago, and a specific post that essentially entails creating and running an AppleScript that will monitor your usage and launch an application when you go "idle".
property idleCheck : 20 as integer
property idleCheck_usr : 120 as integer
set timer to 0
on idle
--Check idle time
set idletime to do shell script "ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'"
set idletime to idletime as string
set idletime to idletime as integer
tell application "System Events"
if idletime is less than idleCheck then (* 20 is 20 seconds. If a key was tapped within the idleCheck seconds, it quits the app. *)
tell application "TextEdit" to quit
return idleCheck -- checks again in ... seconds
else
if idletime is greater than idleCheck_usr then (* If a key was tapped after the idleCheck_usr seconds it opens the app. *)
tell application "TextEdit" to launch
end if
return idleCheck
end if
end tell
end idle
In this case idle is only after 2 minutes, but you can easily change that to be longer if necessary. You will also want to modify the line to open Transmission instead of TextEdit.
Note that you will have to open this AppleScript and leave it running in order for the action (launching an application on idle) to ever occur.
Have you tried using Scenario? It is on the Mac App Store. While I haven't tried it myself. It seems that it might do what you need. Hope this helps.
How about Sleepwatcher?
"SleepWatcher 2.2 (running with Mac OS X 10.5 to 10.7, source code included) is a command line tool (daemon) for Mac OS X that monitors sleep, wakeup and idleness of a Mac. It can be used to execute a Unix command when the Mac or the display of the Mac goes to sleep mode or wakes up, after a given time without user interaction or when the user resumes activity after a break or when the power supply of a Mac notebook is attached or detached. It also can send the Mac to sleep mode or retrieve the time since last user activity."
To launch an app (using a command), you'd have to do something like the following:
open /Applications/Transmission.app