Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I extensively use Launchbar and have almost all my daily productivity items working through it.

Since I use my personal MacBook at work, I do not have use a screen saver password, however, when at work, when I leave my desk, I use the Lock Screen feature of Keychain to lock my machine. When at home it hardly ever gets locked, so putting a password on the screensaver is really not useful to me.

I have searched far and wide, but can't seem to find a way to have Launchbar emulate the Lock Screen feature of the Keychain.

Any suggestions on how this can be achieved using Launchbar?

I would also be happy if someone can just provide me with guidance on an AppleScript that can achieve my goal?

Solution

bmike gave a very usable solution, however I ended up purchasing Lock Screen 2 from the App Store which allows you to set a hotkey to lock your screen among other options.

share|improve this question
1  
The start screensaver command is the easiest way in conjunction with enforcing password, but since you asked... –  bmike Sep 20 '11 at 13:59
    
@bmike — This is what I would recommend as well. Using the "Hot Corner's" option in conjunction with the screensaver you can lock things down instantly. There's an option to display the Keychain Access in the Menubar too, which is also quick. –  l'L'l Sep 20 '11 at 15:56
    
@ioi As I mentioned, putting a password on the screen saver is not an option for me, since it is a hinderance 80% of my usage time. I already use the Keychain Method, just need another way to trigger it. –  Diago Sep 20 '11 at 16:17
add comment

3 Answers 3

up vote 5 down vote accepted

First you need a script. There are countless ways to script things, based on individual skills and knowledge of AppleScript or other languages. For simplicity, let's use automator.

You will want to use the Watch Me Do action to show Automator how to trigger the menu item to lock the screen.

enter image description here

I made this a service, since I like to use FastScripts for something like this. Launchbar will find your service as the top hit if you name it LockScreen as I did in this example when saving from Automator.

(You can make an Application and store it in Apps, but services seem more light weight to me and perhaps a little faster...)

To start, click the record button at the top. Once the screen locks and you get back in, do edit down the action - you can get rid of the "ScreenSaverEngine" task if recorded you getting back in before you stopped the "recording"

I moved the Playback speed to the max. I also told automator that this service receives "no input" just under the record button.

Here is what you should have after saving your new service. Pay attention to the requirements of the Watch Me Do action in the lower left if you have any problems with training your mac to sing itself a short lullaby.

enter image description here

share|improve this answer
    
Awesome. I never though of doing it this way. It does require me to keep the menu item, however I can live with that! I will give this a try once I am home. –  Diago Sep 20 '11 at 14:15
    
This is the slowest, but easiest intro to scripting. Once you get this, you can then look into Apple Script Editor - see if the keychain dictionary exposes the lock command. The nice thing about the menu is that it's always running and you don't have to wait for keychain access to launch itself. –  bmike Sep 20 '11 at 14:20
    
I worked with this and it is the closest free built in solution available. Since this answer is complete, I am accepting it. However I did update my question with the solution I ended up going with. –  Diago Sep 20 '11 at 17:16
    
Don't feel you need to accept this - I've got enough points for today|this week|probably forever. Go ahead and answer your own question with the solution that works for you. This answer will get up votes if others like it just like your answer can too. –  bmike Sep 20 '11 at 17:43
add comment

A simpler version is here: http://www.harukizaemon.com/2008/02/lock-your-screen-with-launchbar.html

Repeating it (with an update for LaunchBar 5):

  • Open the the Script Editor, /Applications/AppleScript/Script Editor
  • Enter the text activate application "ScreenSaverEngine"
  • Save it to ~/Library/Scripts/Lock Screen
  • Open the LaunchBar
  • Press ⌘⌥I
  • Select "Actions"
  • Click "Options"
  • Check "~/Library/Scripts/"
  • Click "Index"
  • Click "Update" to make sure your index is up-to-date.
  • Close, saying yes to save.
share|improve this answer
add comment

In AppleScript:

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

This doesn't require you to keep the menu bar item.

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.