5 Answers
5

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.

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.

"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:

As Jason mentions in his answer, Apple's implementation of idle time is difficult to predict. Power Manager uses a measure of inactivity based on user activity; this is easier to predict and more likely to be what you are looking for.