Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pjrobertson

macrumors 6502a
Original poster
Nov 14, 2007
533
4
So, here's the deal. I've copied an applescript seen here:

http://safari.oreilly.com/1565928415/aplscptian-CHP-12

The script is:

tell application "Keychain Scripting" to lock

I was hoping to add this to a quicksilver trigger to lock my 1Password keychain whenever I needed to.

(I've tried the other method mentioned at O'Reilly;
tell application "Keychain Scripting"
if (not locked of keychain "1Password") then
lock keychain "1Password"
end if
end tell

but I get an applescript error "Can’t make locked of «class ckc » "MyPasses" of application "Keychain Scripting" into type boolean"
)

The first script I mentioned works half the time, but ONLY if the 'login' keychain is unlocked. If it's already locked, and I run the script, then none of the other keychains will be locked, but if it's unlocked and I run the script, then the login keychain will lock.

Slightly strange behaviour, and I'm hoping someone here can shed some light on the situation, or come up with a better solution.
I've added the keychain icon to the menu bar to lock the keychain from there, but I'd prefer a trigger / keyboard shortcut.

Thanks
 

roustk

macrumors newbie
Jul 14, 2006
12
0
I am not good at AppleScript at all but what if you use the "security" command-line utility directly:

Code:
security lock-keychain 1Password.keychain
 

pjrobertson

macrumors 6502a
Original poster
Nov 14, 2007
533
4
Good idea!

I added it as a trigger in quicksilver under the 'run in shell' command and it's working :D

Thanks
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.