Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Old 08-01-2005, 02:46 AM   #1
Dredog
Prospect
 
Join Date: Jul 2005
Posts: 6
Simple Script to Turn Off iMac Display

Well, I'm pretty sure that there isn't a way to turn off my iMac display unless I turn off my computer.

However, I am just learning to script and was wondering if someone could make a simple script that:
(1) Sets my display to minimum brightness
(2) Set display to sleep as soon as possible

This is only work around I can think of. Any help would be greatly appreciated.

Thanks guys

PS: I have a iMac G5 running Tiger
Dredog is offline   Reply With Quote
Old 08-01-2005, 04:26 PM   #2
giskard22
Moderator
 
Join Date: May 2003
Posts: 4,272
You could use the 'pmset' command.

Have you considered using the screen saver function? You could create an image that is all-black and put it in its own folder somewhere. Then, in the screen saver prefs, use the "Choose folder" option to select that folder. Presto, an all-black screen saver. Set one of the Hot Corners and you can turn it on immediately. It can even require a password to get out of if you want.
giskard22 is offline   Reply With Quote
Old 08-02-2005, 12:51 AM   #3
Dredog
Prospect
 
Join Date: Jul 2005
Posts: 6
WOW!!! Never thought of that!. Thanks the screen saver trick seems like a nice work around.

I don't know what pmset is. Any articles i can read about it?

Last edited by Dredog; 08-02-2005 at 12:54 AM.
Dredog is offline   Reply With Quote
Old 08-02-2005, 09:22 AM   #4
djhayn
Triple-A Player
 
Join Date: Oct 2004
Posts: 68
isn't a black image the worst color for an LCD display? either way you still are at the same brightness and the backlight is on, right?

You can kind of do it in applescript. This is the best I could figure out with a quick search but is by no means an easy answer, it has to start the system prefs then quit it.

Code:
tell application "System Preferences"
	set current pane to pane "com.apple.preference.displays"
	tell application "System Events"
		set value of slider 1 of group 2 of tab group 1 of window 1 of process "System Preferences" to 0
		display dialog "Click ok" buttons {"OK"} default button 1
		set value of slider 1 of group 2 of tab group 1 of window 1 of process "System Preferences" to 1
	end tell
	quit
end tell
it sets the brightness to min and then waits till you click ok and brings it back but with the screen dim how do you see the ok button? is there a way to make sure the dialog is the frontmost window so you can just hit return?
djhayn is offline   Reply With Quote
Old 08-02-2005, 09:39 AM   #5
giskard22
Moderator
 
Join Date: May 2003
Posts: 4,272
'pmset' is a shell command. You didn't say what kind of scripting you were learning, so I guess I assumed you were doing stuff with the Terminal. If you open the Terminal and type pmset you'll get a very brief summary of what it does. Typing 'man pmset' gets you more details. It's a command to control the settings that you would normally change in the Energy Saver preferences.

Djhayn, I'm not sure what you mean by "worst" color for an LCD. And yes, the backlight is still on, but the fact that the display is black means that the light isn't coming through. It would still be smart to have the display turn off after a few minutes, but you might as well just use the screen saver first.
giskard22 is offline   Reply With Quote
Old 08-02-2005, 10:38 AM   #6
djhayn
Triple-A Player
 
Join Date: Oct 2004
Posts: 68
just did some digging around on this site here I found this:
http://www.macosxhints.com/article.p...40120215017652

which links to:
http://wincent.org/article/articleview/36/1/8/

Wincent has a good tutorial for adding the shell script to the apple menu. He also explains what I meant by worst:

"Unlike normal monitors, LCDs are working their hardest when they are displaying a black screen. This is because the LCDs (the diodes, that is) have to block all the light coming from the backlight in order to darken each pixel."
djhayn is offline   Reply With Quote
Old 08-02-2005, 10:44 AM   #7
djhayn
Triple-A Player
 
Join Date: Oct 2004
Posts: 68
Quote:
Originally Posted by giskard22
'pmset' is a shell command. You didn't say what kind of scripting you were learning, so I guess I assumed you were doing stuff with the Terminal.

My fault, it was posted in the UNIX help, that would be the only downside of reading this forum through RSS, don't notice the categories.
djhayn is offline   Reply With Quote
Old 08-02-2005, 10:50 AM   #8
giskard22
Moderator
 
Join Date: May 2003
Posts: 4,272
Quote:
Originally Posted by djhayn
"Unlike normal monitors, LCDs are working their hardest when they are displaying a black screen. This is because the LCDs (the diodes, that is) have to block all the light coming from the backlight in order to darken each pixel."

Well, yeah. Anyone who knows how an LCD works knows that that's technically true, though we should quibble with the word "hardest". It would be most correct to say that an LCD is using the most amount of electricity under those conditions. But that doesn't mean you're shortening the life of the display. Any display engineers on this forum want to say one way or the other? My guess is that of the total amount of power used, the backlight takes up the vast majority of it. That's why "passive" LCDs without a backlight, like on a digital watch, can go for years on tiny batteries.

It's a fairly academic question anyway. I doubt most people would turn off the Energy Saver settings entirely.
giskard22 is offline   Reply With Quote
Old 04-10-2008, 12:05 AM   #9
MrMoneybags
Registered User
 
Join Date: Apr 2008
Posts: 1
You can use Shades. Its free (just google Shades OS X). It lets you controll screen brightness. Be sure to look at the preferences carefully. You can even set key combos to make the screen dimmer and lighter. For 10.3 and up.
MrMoneybags is offline   Reply With Quote
Old 04-28-2008, 03:10 AM   #10
ant1ers
Registered User
 
Join Date: Apr 2008
Posts: 1
Easy way to sleep monitor

Control+Shift+Eject

Works on my iMac with Leopard.
ant1ers is offline   Reply With Quote
Old 04-28-2008, 07:32 PM   #11
ThreeDee
Hall of Famer
 
Join Date: Aug 2005
Location: USA
Posts: 3,418
In Terminal:

Code:
pmset force -a displaysleep 107374183
Note this this is an unsupported workaround. The "107374183" somehow confuses pmset into thinking "0". You can't just type 0, as then the monitor would never sleep.
__________________
15" MacBook Pro (Mid 2010), 2.4 GHz Core i5, 10.6.5, 4GB RAM
PowerMac G4 "Quicksilver", 733 MHz, 10.4.11, 1.5GB RAM

iPod Touch 5G, 32GB, iOS 6.1.3
ThreeDee is offline   Reply With Quote
Old 12-08-2008, 11:58 AM   #12
arifsaha
Prospect
 
Join Date: Jul 2007
Posts: 18
Quote:
Originally Posted by ThreeDee
Code:
pmset force -a displaysleep 107374183
Note this this is an unsupported workaround. The "107374183" somehow confuses pmset into thinking "0". You can't just type 0, as then the monitor would never sleep.


Wow, good trick! But be careful when using this command because if you run it just like that you will lost access to your monitor (the display will stay dark, keyboard and mouse reactivate it only to shut down again before it fully reactivate).

I create this little script to use this "feature" nicely:

Code:
#!/bin/sh
# SPAS 2008L7 by S P Arif Sahari Wibowo http://www.arifsaha.com/
DispSleepOri=$(pmset -g | grep displaysleep | awk '{ print $2; }')
pmset force -a displaysleep 107374183
sleep 2
pmset force displaysleep ${DispSleepOri:=30}
Not only the setting will be returned to previous setup, but you have 2 seconds after executing this command where you can close your keyboard drawer and park your mouse without reactivate the screen.
__________________
--
http://www.arifsaha.com/

Last edited by arifsaha; 12-09-2008 at 08:04 AM. Reason: fix quoted message
arifsaha is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 11:43 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.