Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do you create a keyboard shortcut that activates fast user switching (i.e. brings up the login window) in Mac OS X Snow Leopard?

I'm trying to emulate the Windows Start+L keyboard combination, which I miss from my time using Windows.

share|improve this question
    
while smalltown doesn't fix his answer, you may want to check this: macosxhints.com/article.php?story=20050706194219822 or that: artofgeek.com/2009/09/08/… –  Cawas Apr 15 '10 at 2:02
add comment

10 Answers

Check Fast User Switching with Butler and Butler.

share|improve this answer
add comment

Well Strictly speaking -- Command-Option-Q will log you out (with "Are you sure prompt")...

But I don't see anyway to trigger a fast user switch via keyboard... Now you could write an applescript, which you could associate with a keystroke. For example, see http://www.macosxhints.com/article.php?story=20080401232826118 for implementation details.

set thePassword to "password"
set N to name of (info for (path to me))
set AppleScript's text item delimiters to (".")
set N to first text item of N
set AppleScript's text item delimiters to ""
set N to do shell script "/usr/bin/id -u " & N
do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID " & N
tell application "System Events"
    tell process "SecurityAgent" to set value of text field 1 of group 1 of window 1 to thePassword
    click button 2 of window 1 of application process "SecurityAgent"
end tell

share|improve this answer
    
That's seriously hardcore. –  Brian Willis Sep 22 '09 at 8:44
    
@Benjamin, It's Command+Shift+Q –  notnoop Nov 17 '09 at 15:01
add comment

For 10.6 Snow Leopard, one can easily add a Service using Automator, and then assign any keyboard shortcut using System Preferences. See Fast User Switching/Apple Menu? for details.

share|improve this answer
add comment

According to Király in Apple Support Discussions, he says this combination works:

...This can be done with Automator and Spark:

Open Automator, select Run Shell Script, and paste in this (all on one line):

/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend

File -> Save As... -> select "Save as application" and save the app in a convenient spot. Then use Spark to assign a keyboard shortcut to open that app.

I use Automator and Spark to switch to the login window and then put my Mac to sleep when I press control-F13...

About Spark 3.0b9 software:

Spark is a powerful, and easy Shortcuts manager. With Spark you can create Hot Keys to launch applications and documents, execute AppleScript, command iTunes, and more... You can also export and import your Hot Keys library, or save it in HTML format to print it. Spark is free, so use it without moderation!

share|improve this answer
    
PS: You could also see what's up with other suggested scripts already out there: • AppleScript: Account Switcher Applet macosxautomation.com/applescript/accountswitcher/index.html –  in a small town Feb 9 '10 at 8:21
    
This answer is way too big and quite confusing to read, and you don't really need **Spark**at least for Snow Leopard. Just create that on Automator as a Service and add a shortcut to it on System Preferences. I'll add an answer myself if you don't fix yours, smalltown-dude. ;) –  Cawas Apr 13 '10 at 19:30
add comment

if you have quicksilver, i've create a little app that can be used with triggers in QS. more info: http://davidjmccrea.tumblr.com/post/584507546

David

share|improve this answer
add comment

If you are at the CLI, you could have the following alias set to switch quickly:

alias switch='/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend'
share|improve this answer
    
This and fastscripts and automator make fast work of needing a CLI handy. –  bmike Aug 15 '11 at 22:20
add comment

A slightly different way of doing this, with added security benefits (or annoyances depending on your view-point), is to

  1. use the screen saver to lock the computer (allowing user switching from the lock screen)
  2. use "hot-mouse-corners" to enable fast locking/screen-saver activation

To do this, you need to adjust the following settings in your System Preferences application:

  • Under Exposé & Spaces, in the Exposé tab, set one of your Active Screen Corners to Start Screen Saver.
  • Under Security in the General tab, check the option of Require password ... after sleep or screen saver begins (you may want to choose immediately from the drop-down).

You'll have to do the latter on each account (unfortunately there's no global setting for this).

Then you can move your mouse to the appropriate corner of the screen to lock the computer (by starting the screen saver). When someone presses a key/moves the mouse they'll be prompted to log in and can switch users from there.

share|improve this answer
add comment

I use BetterTouchTool for a lot more than just this but, one of the actions it allows you to do is "Show the Login Screen" (which is different from logging out and leaving you at the login screen). I use it ALL THE TIME to lock my machine when I leave it for extended periods of time… Here's a screenshot:

enter image description here

share|improve this answer
add comment

If the desire is to lock (like Window-L in Windows), then there's a very simple solution .. set your screensaver to lock the screen (require logon) and use ctrl-shift-eject (bottom left two keys + top most right key). This locks your screen.

share|improve this answer
add comment

To switch to a specific user I invoke a script I found in the comments of a hints.macworld.com article. I had problems with it so I tweaked it to get if to work. The password is stored in the keychain, so you don't have to worry about storing login password in cleartext. You can find the gist here.

--This script MUST be named "Switch to User.scpt", where User is the name of the user to switch to.
--You must first make a password item (a.k.a. a key) for the other user's password using Keychain Access, and call it "", where "user" is the other user's name and with the description "User Login". The script assumes that you make this key in your login.keychain, which is the default one.
--The first time you run this script, you will be prompted to allow Keychain Scripting to access the password of the key.
--This script requires "Enable access for assistive devices" to be enabled in the Universal Access system preference pane.

set username to word -1 of my findReplace(".scpt", "", (path to me as text))

-- Invoke Fast User Switching. The `id -ur username` part gets the uid number that corresponds to the username and substitutes it at the end of the CGSession command
do shell script "/System/Library/CoreServices/'Menu Extras'/User.menu/Contents/Resources/CGSession -switchToUserID `id -ur " & username & "`"

-- Use universal access to enter the text and to click the button
tell application "System Events"
    repeat
        if (do shell script "stat -f %Su /dev/console") is username then exit repeat

        -- Get the password for the username
        try
            set pswd to (do shell script "security find-generic-password -g -s \"" & username & "\" -D \"User Login\" 2>&1 1>/dev/null | sed -e 's/password: \"//' -e 's/\"//'")
        on error
            exit repeat
        end try

        if exists window 1 of application process "SecurityAgent" then
            tell process "SecurityAgent" to set value of text field 1 of window 1 to pswd
            key code 36
            exit repeat
        else
            tell application "SecurityAgent" to quit
            do shell script "/System/Library/CoreServices/'Menu Extras'/User.menu/Contents/Resources/CGSession -switchToUserID `id -ur " & username & "`"
        end if
    end repeat
end tell

on findReplace(findText, replaceText, sourceText)
    set ASTID to AppleScript's text item delimiters
    set AppleScript's text item delimiters to findText
    set sourceText to text items of sourceText
    set AppleScript's text item delimiters to replaceText
    set sourceText to sourceText as text
    set AppleScript's text item delimiters to ASTID
    return sourceText
end findReplace

To just invoke the Login Screen I have another script. You can find the gist here

do shell script "'/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession' -suspend"

Both scripts are in my quicksilver catalog. Switching between user accounts is a matter of a few seconds.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.