Jump to content

Recommended Posts

After searching around online for a way to automate sleeping my display rather than the whole computer, I realized there wasn't a good solution. So after some trial and error, I whipped up an AppleScript and created a workflow around it.

 

Dependencies

Requires Extra Suites, an unmaintained application that allows one to script mouse movements. One can download it here: http://www.kanzu.com/downloads/Extra_Suites.zip

 

Download

http://cl.ly/PV97

 

Hope this is useful!

 

-Bruce

 

 

 

Link to comment

Wow! You're right, there's not much in the way of options for doing this. Rather than scripting mouse movements, did you come across this in your searching? I have no idea if it still works, but it seems to be someone else's solution to the same problem :-)

 

Oh, and I'm not sure what your use-case is, but have you considered the in-built OS X keyboard shortcut for sleeping the display? Shift+Ctrl+Eject.

Edited by Subject22
Link to comment

I hadn't come across that, though I'm not a developer, so I like to stay in scripting land. Also, "Hi. The problem is that with some machines it causes a kernel panic" is worrisome. ;)

Extra Scripts instantaneously transports the mouse to the pixel coordinates; there's not really any delay.

As for the built-in shortcut, my muscle memory is better for Alfred and I don't have to stretch across the keyboard to the Eject key.

Yes, I'm lazy.

-Bruce

Edited by brucehs
Link to comment
I believe the kernel panic issue was with PPC machines, not the Intel one you're doubtless using. There's an app available that simply executes that code and the reviews for it seem positive. You could either bundle the app with the workflow and call it with an AppleScript to eliminate the need for additional installs, or try to roll your own script with the code linked above (relinked for posterity). Of course you may be completely happy with your current solution, there's really nothing wrong with it (apart from requiring an additional download). It's less worrisome than executing code of uncertain providence, but you could give it a shot anyway. What's life without a little experimentation? :P
 

AppleScript has built-in support for scripting key presses so I had assumed that if you didn't like the system shortcut then you could have written an AppleScript to press those keys for you (with an accompanying workflow to tie the script to a key combo of your choice), but it seems that the eject key is not scriptable.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...