blog advertising is good for you


blog advertising is good for you
User login

Turning Displays Off

eric asks:

Question

Like most people i’m sure, my computer is in my bedroom, and is on 24/7. I have my apple displays automatically sleep after 15 min of inactivity, but when i go to sleep i want them to go to sleep immediately. The best way i’ve been able to do this is to go to the energy saver control panel every night and change it to 1 min before putting them to sleep, then change it again in the morning. ugh!

What i would love to do is reprogram the power button on my 23’‘ display to put both displays directly to sleep. A simple display ‘off’ button.

thanks for the help guys

Answer

Average rating
(1 vote)
About Adam Knight
Adam Knight's picture

Author Biography

Adam Knight is one of the founders of Mac Geekery and is a geek at heart. Programmer by day, hacker by night, his daily life revolves around the Macintosh platform, which he has been a user and programmer for since the early days of System 7 when his LCII replaced his Apple //c.

In-between tech jobs, he’s managed to learn the basics of any web hacker: PHP, MySQL, Perl, Apache, Linux, *BSD, and the intricacies of ./configure —prefix=~/bombshelter/. Today, codepoet is concentrating on blogging again, writing some software for the Mac by himself (including Notae) and for his company (such as Switchblade) and has a few other toys coming out soon.

Bug him over AIM or email [link fixed].

Adam Knight's picture

No, it won’t happen at the same time, but it’s as good as it gets. Smiling

Aww man, and here I was hoping for a solution I could use with my built-in iMac display.

Currently I use a screensaver that displays a black screen (i.e. the default screensaver template, with no code added). But it’s still glowing. I’ve always wanted to make the screensaver actually shut the display off, but I’ve never known how.

JC's picture

if you hit the power button, it’ll put the whole machine to sleep.

I have a MacBook Pro. When I want the display to turn off immediately but I don’t want to put the whole machine to sleep, I just hold down the Brightness Down button (or whatever it’s called); the last “notch” on the setting turns the back lighting on the display completely off. On non-laptop keyboards, F14 should do the same thing (and F15 turns the brightness up). That should work for you, Eridius.

Ray Gun Robot: Tech with Personality

I have an AppleScript at home to make iTunes’ volume fade to zero over a period of time. One of the features of this script is to set the Energy Saver prefs so the display sleeps within a few minutes. The original Energy Saver prefs are then restored.

Could the Display section of the Energy Saver prefs be set to the lowest possible value (a quick power off of the screen), the script pause long enough to cause the screen to turn off, and then the script set the original Energy Saver prefs?

I can’t claim to have written the script though, it’s here:

http://www.hoboes.com/Mimsy/?ART=405

The interesting parts surround the “pmset” command.

- Patrick

Adam Knight's picture

Okay, okay, here’s something that actually does something useful:

sudo pmset -c displaysleep 1; sleep 61; sudo pmset -c displaysleep 30

In one step this sets the time for the display to sleep to one minute, waits until the display sleeps, and then puts it back to 30 minutes (presuming that’s where you had it).

So, just make a command file out of this, open it, enter the password, and go to bed. The computer will take care of the rest. It’s not instant, but it’s not manually farking with the Energy Saver panel, either.

This solution probably only works with the latest generation of Cinema Displays. The Displays Preferences with my ‘old’ Apple Cinema HD Display (23”) just gives you 2 checkboxes to check, none of which you can turn off your display.
Further more, the Brightness control keeps the screen glowing.

So, anyone for a ‘real’ solution? (besides fumbling with the Energy Saver Control Panel)

Adam Knight's picture

There really isn’t one. You have two choices for display power:

  • Turn off the backlight
  • Turn off the display

For portables, you can turn the brightness all the way down and the last step turns off the backlight entirely. For the metal Cinema Displays, you have the above option to turn them off separate from the computer.

Everyone else is generally screwed. The brightness on iMacs and Cinema Displays doesn’t turn off the backlight, and plastic displays do not have the option to be off separate from the CPU.

And that’s the way Apple fumbles.

JC's picture

The Displays Preferences with my ‘old’ Apple Cinema HD Display (23”) just gives you 2 checkboxes to check, none of which you can turn off your display.

I don’t have a setup like that anymore, but we had them previously, and used these options extensively. I’m not sure why you’re not seeing them? I think Apple added the option in Panther or Tiger…

This is a good answer to immediately sleep the display:
http://www.apple.com/downloads/dashboard/status/sleepdisplay.html

There’s also an application version on the developer’s site:
http://linestreet.googlepages.com

Mr. Anonymous,

I have been looking for that little gem for something close to four years now. I needed it on my plastic ACD with ADC connector (alphabet soup!) and I need it on my iMac today. Thanks!

I guess I’m looking at this topic at just the right time! That sleepdisplay app/widget combo is just the ticket.

Since widgets are interpreted, not compiled, you can look at the source code to see how it’s done. Based on that code, here’s a shell script you can use, if you prefer to sleep the display from the command line:

#!/bin/sh

MAGIC_NUMBER=107374183

PMSET=/usr/bin/pmset
GREP=/usr/bin/grep
AWK=/usr/bin/awk
SLEEP=/bin/sleep

$PMSET force -a displaysleep $MAGIC_NUMBER
$SLEEP 1
$PMSET force -a displaysleep `$PMSET -g | $GREP displaysleep | $AWK '{print $2}'`
$SLEEP 1

Now I just need a way to wake the display again from the command line… Smiling

and here is an applescript version that works, for those of you who want to reuse this in applescript – very useful …

do shell script (“pmset force -a displaysleep 107374183”)
delay 1
set dsvalue to last word of (do shell script “pmset -g | grep displaysleep”)
do shell script (“pmset force -a displaysleep “ & dsvalue)


the force modifier, tells power management to use the new setting without writing to disk (so you don’t need root access). and since it hasn’t been written to disk, you can easily get the value that is stored on disk (with the -g modifier) and reset the display sleep to that number. that way, once you wake the display, it won’t instantly go back to sleep again – and it is reset as your current profile (whatever that is – ac power, battery power, best, custom, etc. .. .)

why the number 107374183 (which is supposed to be a number of minutes) makes the screen go dark instantly, i have no idea. probably related to ‘lost’ …

Adam Knight's picture

107374183 is one more than the integer will hold, cycling it over to zero. Entering zero directly will toggle the setting off.

I have a situation. I have 2, 23” displays both brand new within the past 2 months. I want the whole machine to go to sleep when i set the display option of the power button to “puts system to sleep or wakes it.” Instead, for some odd reason, the button shows the shutdown dialogue screen with the options etc… I am running a Power Mac G4 (MDD) Dual 1.42GHz with a GeForce ti 4600 1xDVI and 1xADC. Not sure why i cant put it to sleep with the button that says i can do so, any suggestions on how to go about fixing the button issue?

Post new comment
The content of this field is kept private and will not be shown publicly.
4 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.