Sleep Display Script
Posted in Mac OS X, Shell on 11/27/2007 05:08 pm by jmccuneHere’s a quick script I cooked up to turn off the blinding light that is my iMac display when I go to bed at night.

Features:
- Runs great from Quicksilver.
- Talks to you. (May not be a feature.)
- Doesn’t require administrative rights.
#!/bin/bash # Jeff McCuneexport CURRENT_DELAY=$(pmset -g | grep displaysleep | awk '{print $2}') # Charger or Battery Flag. pmset -g | grep -q '^AC.*\*' && export MODE="-c" || export MODE="-b" say "The display will shut off in about 90 seconds" & # force allows this to work for non-admin users. pmset force $MODE displaysleep 1 # Quicksilver blocks until script completion. Fork off the reset command. bash -c 'sleep 120; pmset force $MODE displaysleep $CURRENT_DELAY' & exit 0