My idea is to dim the display when the system is idle for 10 seconds, and with a keystroke or trackpad activity revert to original (I want to preserve battery automatically and not using a screen saver - I need to monitor some activity but with low display light). I could not find such application so I decided to make solution with Automator.

I found application Shady which can dim display when it start and if it is active (in front) with keystroke Q will quit.

So, how can I make a script in Automator to start Shady when the system is idle for 10 seconds and then wait for any keystroke or trackpad activity, then send keystroke q to quit Shady? The script should be active all the time, so when another 10 second idle time happens, start Shady again.

  • I doubt that automator can detect when the system is idle. (But proving me wrong is always welcome) Oct 11, 2013 at 23:02

1 Answer 1


If you want to actually save energy, use brightness.c instead of Shady. Shady doesn't reduce the backlight levels of displays, and LCDs usually require a similar amount of energy to display dark and bright pixels.

You can see the time since the last human input device (keyboard or mouse) action with ioreg:

ioreg -c IOHIDSystem | awk '/HIDIdleTime/{print $NF/1000000000;exit}'

If you are for example wathing a video with VLC, pmset -g assertions will contain a line like this:

   PreventUserIdleSystemSleep     1

So you might use a script like this:


while sleep 0.5; do
  idle=$(ioreg -c IOHIDSystem | awk '/HIDIdleTime/{printf "%i",$NF/1000000000;exit}')
  current=$(brightness -l | awk '/display 0: brightness/{print $NF}')
  if [[ $idle -ge 10 ]] && pmset -g assertions | grep -q 'PreventUserIdleDisplaySleep *0'; then
    [[ $current != 0.000000 ]] && old=$current
    brightness 0
    [[ $old ]] && brightness $old

It doesn't make any sense to execute over ten new processes every second though.

  • Thanks a lot! Definitely then brightnesss.c is option. I tried with your code and precompiled 'brightness' but I stuck. I am not so good in OS X coding, can you help me or guide me to make application with Platypus or similar? Just need default 10 sec idle time from the last human input device (HID) and to run resident in background. Oct 12, 2013 at 18:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .