Turn off display on imac

Is there a way to use applescript to turn the display off?

I would like to be able to click an icon and make the display turn off like what happens with the energy saver mode.

And before you ask, I dont want to use the energy saver control panel:

  1. I want the computer running all the time.
  2. When I watch a movie, i dont want the display to keep turning off.
  3. I dont want to keep switching the energy saver mode on and off.

I would like an applescript (or app) that turns the display off.

I would like this to work on a mactel imac if it matters.

i watch my movies in full screen mode and the monitor has never turned off on me.

You can make the display sleep immediately with the AppleScript line:

activate application "ScreenSaverEngine"

You can’t power it down and leave the processor running if it’s part of the Mac -

this isn’t instant (takes a minute) but puts the screen to sleep and keeps it there…



do shell script ("pmset dim 0") password ¬
		"Mypass" with administrator privileges
	

or can be used with variables, as in my app:


property sleepytime: "0"
property passme : "Mypass"
do shell script ("pmset dim " & Sleepytime) password ¬
		passme with administrator privileges
	

to reset, change the “0” to however many minutes you would like to wait before screen sleep.

“dim” is deprecated (still works but might not continue to). It is now (10.4) called “displaysleep”. Similarly, “spindown” is now called “disksleep” in pmset.

sorry. 10.2 still. wish apple still gave us software for free :confused:

This is kind of like a sleep timer like on a television…you can enter in how many minutes you want the display to turn off (default 1 min).
It also has a button that you can set your normal display shutoff time on, so that you can easily change it back
without going through syst pref–>energy saver manually.
This will set your display shutoff time to whatever you enter,
so your display will shut off after that amount of minutes until you change it back,
either using the script or through energy saver.


global response

tell application "Finder"
	display dialog "Sleep Time:" default answer "1" buttons {"Ok", "Turn off Sleep"} default button 1
	
	copy the result as list to {text_returned, button_pressed}
	
	set response to text_returned
	
	if the button_pressed is "Turn off Sleep" then
		set response to "number_of_minutes_your_normal_display_shutoff_time_is"
	end if
	
end tell

set shelly to ("pmset displaysleep " & response)

do shell script (shelly) ¬
	user name ¬
	"adminusername" password ¬
	"passwordhere" with administrator privileges


Model: powerbook g4 1.67
Browser: Safari 417.9.2
Operating System: Mac OS X (10.4)