How to run commands when mac is idle and when it resumes

2

I want to run script when my mac is idle (for example after 5 minutes or screen saver start time is also ok) and when I resume it from idle state.

I know that I can write daemon using NSDistributedNotificationCenter and com.apple.screenIsLocked and com.apple.screenIsUnlocked, but I hope that there is already solution without creating new daemon.

I need this to for example turn on/off speed limit for Transmission (as it is sometimes hard to work when hashing/downloading on full speed).

tig

Posted 2010-05-09T13:41:15.157

Reputation: 3 906

Answers

1

JRobert

Posted 2010-05-09T13:41:15.157

Reputation: 6 128

I see how you can script 'sleep' events, but not when your machine goes to idle / inactive. – brianegge – 2011-05-31T15:36:25.063

From Sleepwatcher's help text: -i or --idle execute idlecommand when no user interaction (keyboard, mouse) took place in the period given with the -t option. – JRobert – 2011-05-31T16:09:37.817

0

Look at the batch command:

man batch

Hai Vu

Posted 2010-05-09T13:41:15.157

Reputation: 4 824

Man page says about queueing at specific time or when load average drops below special value, nothing about idle/resume – tig – 2010-05-12T10:31:48.663