mind the explanatory gap

many a slip ‘twixt mind and lip…

mind the explanatory gap RSS Feed

Finally… a sanctioned way of activating the screen saver.

Ever since I started managing Macs in a corporate environment, I’ve been annoyed that Apple has failed to offer a sanctioned way of locking the screen via a keyboard command. This is a reasonably common requirement in a lot of corporate deployments. Sure we can use hot corners etc, or we can use one of the sanctioned methods to activate the loginwindow via Fast User Switching, but the former isn’t for everyone, and the latter sucks because it will tear down userspace VPN/802.1x connections.

We have reasonable MCX controls to require a password for the screensaver, but nothing to actually activate it. There are a bunch of private API calls you can use to achieve this, but using private APIs makes me feel dirty.

When I first started poking at Automator again in 10.6, I was pleased to notice that we have a “Start Screen Saver” action. This means that we can save such an Automator workflow as a Service, and then assign a keyboard command to it such that we can activate it from any application.

Unfortunately this action is buggy. If you activate the workflow and wiggle the mouse around, you’ll get an error dialog after unlocking the screen.

Luckily we have another way of achieving the same goal. The System Events AppleScript dictionary contains the same functionality.


tell application "System Events"
start current screen saver
end tell

So you can simply create an Automator “Service” workflow and add a “Run AppleScript” action with the following code snippet.


on run {input, parameters}

tell app "System Events"
start current screen saver
end tell

return input
end run

Save it, and assign a hot key, and you can finally activate the screensaver from the keyboard.

7 Responses to “Finally… a sanctioned way of activating the screen saver.”

  1. Ryan Says:

    You can also use Ctrl+Shift+Eject to immediately put the displays to sleep. If you have configured your computer to require a password to disable the screensaver, then when you move the mouse, the displays will wake and you’ll need to authenticate to access the system again.

    Hope that helps!

  2. nigel kersten Says:

    It’s not the same though Ryan.

    Test it.

    Hit the key combo you mention.

    Wait a few seconds, wiggle the mouse cursor.

    The screen reappears without requiring a password.

  3. nigel kersten Says:

    And before anyone brings it up, yes you can activate the Keychain Access menu item that allows you to lock the screen using the mouse.

    a) It’s using the mouse
    b) I dislike cluttering up my menu bar due to living on 13″ laptops fairly regularly.

  4. Paul Lathrop Says:

    Hey Nigel,

    I think Snow Leopard addressed the few second ‘grace period’ for screen locking; I just tried Ctrl+Shift+Eject and it was instantly locked.

    Just FYI.

    –Paul

  5. Fraser Smith Says:

    Sorry to sound dumb but how do you assign a hotkey to the workflow.

  6. nigel kersten Says:

    Look in the Keyboard section of System Preferences. You can assign hotkeys to Services there.

    You do need to make sure you’ve saved it as a Service.

  7. nigel kersten Says:

    Paul (and Ryan for Snow Leopard), you’re absolutely right. I hadn’t noticed this behaviour change in Snow Leopard.

    If you’ve set an MCX control to require a screensaver password, the setting you get in Snow Leopard is that a password is required immediately after screensaver or display sleep.

    Unfortunately we can’t customize the Ctrl+Shift+Eject keyboard shortcut, which is a bit annoying. We like to have a standard keystroke across platforms to lock the screen.

Leave a Reply