First open your favorite text editor (Except for TextEdit or Microsoft Word) and save a file called lockscreen with the contents below. I saved mine in a directory called ~/bin/, but you can put yours anywhere. (Note: ignore the text wrap below—there is no line break in the command)
#!/bin/sh
/System/Library/CoreServices/”Menu Extras”/User.menu/Contents/Resources/CGSession -suspend
/bin/sh kill -3 $(ps wax | grep “[T]erminal.app” | awk ‘{print $1}’)
osascript -e ‘tell application “Terminal” to quit’
Now, we have to make the lockscreen file executable. In Terminal, type:
chmod 754 ~/bin/lockscreen
Set up a Quicksilver trigger
The built-in keyboard shortcut system in OS X can’t easily trigger a command-line script like our lockscreen script. We’ll set up a trigger in Quicksilver to accomplish the same effect.
In Quicksilver, go to the Catalog and add a your lockscreen script.
Next, go the Triggers section in Quicksilver. Add a new HotKey under the Custom Triggers section. Type lockscreen under ‘Select an item’ and click Save (it should automatically find this from the catalog). Then click on the Trigger column to set the keyboard shortcut. I went with Ctrl+Option+Command+L, but choose whichever combination you like.
That’s it—close the Quicksilver window and try out your new keyboard shortcut!
(Modified version from here)







