Detecting when my Mac is "idle"

Recently I've been running a terminal based Java programme, but the programme is often quite laggy while I am playing computer games. During these periods I turn the programme off but then I forget to turn it back on... 1st world problems eh?

So I wrote this script

The script itself is fine. The problems I am mainly having is with the triggers. Currently I am using these triggers.

The problem is that neither of these are particularly efficient... Some days I am up beyond 3:30am, for instance... And waiting for my system to sleep takes time and I guess I just wanted to get it more efficient.... So I've been wondering how I could detect me being idle... One idea was to get the mouse position and detect whether it has moved since 2-3 minutes ago. If it hasn't then I must be idle... But sometimes I play games where the mouse position doesn't really move I don't think... So I'd also need to take into account keyboard inputs and blargh...

So other than detecting when the system sleeps is there a better way to do what I want to do?

Thanks!
~Sancarn

You can use a built-in calculation function to find out how long you have been idle. I’ve used it in this sort of context:
Trigger: Periodically while logged in, Repeating every 1 Minutes (you can limit the time ranges and days of the week too if necessary)
If: The calculation: IDLE > 5*60 returns true (non-zero)
execute the following actions: (whatever you want it to do)

That means whenever I have been idle for 5 minutes (or longer – IDLE returns the idle time in seconds), the actions will be executed.

1 Like

Oh wow! That is incredibly simple then!

Thank you as well - this helped me out a ton! very easy to set up now that I know how!!