View Full Version : [SOLVED] Sleep the Display using Automator
Oct 24, 2009, 10:53 PM
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.
Oct 28, 2009, 08:42 AM
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:
do shell script "pmset displaysleep 1" with administrator privileges
Edit: looks like you can embed the username/password in the script directly:
do shell script "pmset displaysleep 1" user name "user" password "password" with administrator privileges
Nov 21, 2009, 04:40 PM
"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.
Nov 21, 2009, 05:58 PM
As root: Set system time back 2 minutes. Set display sleep to 1 minute. Restore system time. What happens?
Nov 24, 2009, 12:22 AM
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?
Nov 24, 2009, 02:06 AM
Try this :)
Nov 24, 2009, 11:11 PM
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.