You can’t reference the eject key, and there is no syntax to directly sleep the display. Who knew this would be so difficult…
The only solutions I found searching involve shell scripts that temporarily set the display sleep to the shortest setting and then wait that amount of time and set the settings back to what you had. Seems a little clunky to me.
Well, at least I’m not the only one who’s tried to do this.
Has anyone ever found a programmatic way to sleep the display which doesn’t involve waiting for one minute to have pmset do its thing?
I found mentions of a hack that only worked pre-Leopard which used a ‘magic number’ to fake pmset into instantly sleeping the display. But that doesn’t work.
I have a handy script to do the opposite (fake pressing the shift key to wake up the display):
Another possible solution might be to use dockables http://getdockables.com and launching the sleep display app.
I don’t think so because even manually changing my brightness on my Cinema Displays doesn’t turn them the back lighting completely off like it does on a MacBook. Also the display brightness doesn’t work on my Mac Mini at home that has generic DVI monitors plugged into it but display sleeping stops the video from outputting (i.e. control+shift+eject).
Here’s a download link for the SleepDisplay application. It’s tiny, works instantly, and works under OS 10.6 and 10.7 (haven’t tried it under more recent versions). I use it to kill the display on my living room iMac when I run the “Movie” or “Bedtime” macros on my home automation system.