Mountain Lion sleep and caffeinate command
Solution 1:
The assertions are removed when the caffeinate process exits.
caffeinate creates assertions to alter system sleep behavior. If no assertion flags are specified, caffeinate creates an assertion to prevent idle sleep. If a utility is specified, caffeinate creates the assertions on the utility's behalf, and those assertions will persist for the duration of the utility's execution. Otherwise, caffeinate creates the assertions directly, and those assertions will persist until caffeinate exits.
caffeinate
(or caffeinate -i
) prevents idle sleep until the process is terminated by for example pressing control-C or closing a shell window. caffeinate open -Wa uTorrent
would also remove the assertion when open
exits.
You can get a list of power assertions with pmset -g assertions
. caffeinate
or caffeinate -i
should set PreventUserIdleSystemSleep
to 1.
To always prevent sleep when uTorrent is open, you could add a line like this to a crontab:
* * * * * pgrep -x uTorrent && caffeinate -t 60
(Use EDITOR=nano crontab -e
if you haven't changed $EDITOR and don't know how to use vi.)