Sometimes when I'm working and need to go out for lunch I want an easy way to lock the screen of my Mac, so that no one else messes around with it. One way to do that is to set the screen saver to be password protected and then flick the cursor to one of the selected screen corners. Another is to choose "Lock screen" from the Keychain menu. But here are two easier ways.
Login Screen
This AppleScript will flip your screen over to show the login screen without logging you out. In this mode, no screen saver is activated.do shell script "/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession -suspend > /dev/null"
Lock Screen
This script requires that the Keychain menu is displayed. Open up the /Applications/Utilities/Keychain Access application and in its preferences enable "Show Status in Menu Bar", which will display the menu in the picture. Using this script, it will be used to lock the screen. This will work even if your screen saver isn't generally set to require a password.tell application "System Events"
tell process "SystemUIServer"
repeat with i from 1 to number of menu bar items of menu bar 1
tell menu bar item i of menu bar 1
click
try
if name of menu item 1 of front menu is "Lock Screen" then
click menu item "Lock Screen" of front menu
exit repeat
end if
end try
end tell
end repeat
end tell
end tell
Use the icons that are downloadable here and attach them to the scripts and then use QuickSilver to attach them to triggers, such as CMD-F14 for Lock Screen or something like that.