Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

upaymeifixit

macrumors 6502a
Original poster
Feb 13, 2009
787
1
I am looking for a way to sleep my display with an automator workflow. I don't know much about programming (I'm only 15), so go easy on me.

I have though about just doing it by running a shell script, but I don't really know how. I used the "pmset displaysleep 1" command, but I have to log in as root, and I don't know how to do that. Maybe I could have automator do a key command like "Control+Shift+Eject", but it won't record the eject key.

Thanks.
 
I doubt there's a way to get around requiring root, since the pmset manual specifically says it's required, but if you can get Automator to run an AppleScript directly then this is probably the preferred way to do it:
Code:
do shell script "pmset displaysleep 1" with administrator privileges

Edit: looks like you can embed the username/password in the script directly:
Code:
do shell script "pmset displaysleep 1" user name "user" password "password" with administrator privileges
 
Nope

"pmset displaysleep 1" only changes the display sleep time to one minute whereas "pmset displaysleep 0" turns display sleeping off. I don't want either of those.
 
Tried it

Okay so I tried what chown33 recommended and it didn't seem to work, as to why, I'm not sure.

So let me say what I know here. When I do the command "sudo pmset displaysleep 1" Instead of the one meaning on it means one minute, so if I were to replace the one with a 45, it would set the display sleep time to 45 minutes, just like you can do in the system preferences.

The display will only sleep after one minute if it has not been touched (like a screensaver), so I can't move the time forward or backward using the system preferences. I tried to do it (just as a test) using terminal with "sudo date 112322112009" and it sets the time but I think it is resetting the one minute countdown because it detects input.

If I were to put this into an applescript in automator, would it work? If it did work how to I get it to get the current time and execute the command using the time +1 minute? And then how do I tell it to start using a time server again?
 
Woah, thanks.

I wish I could do that. Lack the skillz. Thanks, it works great. Is there any chance you can make one that wakes the screen? It's not that important, but if it wouldn't be too much trouble.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.