Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Lock and unlock a Mac using Bluetooth detection' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Lock and unlock a Mac using Bluetooth detection
Authored by: mech14 on Dec 29, '09 03:17:26PM

To those that are happy to settle for a lesser amount of security, here is the original solution I used, which has AppleScript type out your password explicitly. Keep in mind that this approach requires you to have your password within the 'inrange' applescript in plain text mode!!!

copy the text below into your 'inrange' applescript and give it a shot.

---------------------------------------
tell application "System Events" to keystroke return
delay 1
tell application "System Events" to keystroke "YOURPASSWORDHERE"
-- it types in your password for you
delay 1
tell application "System Events" to keystroke return
-- accept password and log on; this needs the password option to be activated in the Screen Saver options under System Preferences
--------------------------------------

The out of range script can be the following at this point:

-------------------------------------

activate application "ScreenSaverEngine"
-------------------------------------

mech



[ Reply to This | # ]
Lock and unlock a Mac using Bluetooth detection
Authored by: everkleer80 on Dec 30, '09 06:18:33AM

You could use keychain scripting to store and retrieve a pw from the keychain instead of storing it in the script. Also, this way if your pw changes, you just have to change it in the keychain instead of modifying the script. I'm not at my computer right now and I forget exactly how to do this, but I remember it was unbelievably easy.

I think it was something like this:

tell application "keychain scripting"
set thePW to the password of first key of current keychain whose name is "AdminPassword"
end tell

And then just manually create an entry called AdminPassword in your default keychain (or you can modify this to use a different keychain if you want.)



[ Reply to This | # ]
Lock and unlock a Mac using Bluetooth detection
Authored by: mech14 on Dec 30, '09 12:53:36PM

I agree though that this is a better implementation as it doesn't require you to remember to change the passwords everywhere.

Thanks for the suggestion.



[ Reply to This | # ]
Lock and unlock a Mac using Bluetooth detection
Authored by: puzzlebobble on Jan 04, '10 08:47:13AM

thanks to both of you, that works perfectly! I think it requires setting Access Control in Keychain Access to allow access to it by proximity. I currently have access allowed for Proximity, Keychain Scripting and Applescript Editor but think I've ended up with so many permissions because I tested the script out in the editor.

Incidentally, your idea of using proximity for security reasons works really in conjunction with Network Location, by Centrix software (i think marcopolo is a free alternative). When I leave my home (safe zone) Network Location turns on proximity and turns the screensaver password on. Hence if I leave my laptop proximity locks the computer, but when I'm at home the same doesn't happen. Go home: proximity and screensaver password turned off. I find entering the password all the time at home is a pain.

Edited on Jan 04, '10 08:56:34AM by puzzlebobble



[ Reply to This | # ]
Lock and unlock a Mac using Bluetooth detection
Authored by: everkleer80 on Jan 04, '10 08:54:41AM

I'd assume you need Keychain Scripting access since the Proximity applescript is telling Keychain Scripting to get the PW - Keychain Scripting is the one actually making the request for it. The permission granted to Proximity is probably a permission for Keychain Scripting to pass the PW back to Proximity. Of course I could be completely wrong on all of this - I just like to make guesses at how computers work and revise them as necessary - life's all about trial and error!



[ Reply to This | # ]
Lock and unlock a Mac using Bluetooth detection
Authored by: puzzlebobble on Jan 04, '10 09:03:22AM

sounds sensible. It asked my permission for both when I tested the script in Proximity. Pity I can't remember which order it asked. I've turned off access for the applescript editor and it still works.



[ Reply to This | # ]
Lock and unlock a Mac using Bluetooth detection
Authored by: everkleer80 on Jan 04, '10 09:12:55AM

It is nice to know that the app that calls Keychain Scripting also requires permission, because when I fooled with Keychain Scripting once before and allowed it to access my PW, I was worried that I might be allowing ANY applescript to access my PW via Keychain Scripting.



[ Reply to This | # ]
Lock and unlock a Mac using Bluetooth detection
Authored by: puzzlebobble on Jan 05, '10 12:49:43PM

do you happen to know if it is possible to pass a password from the keychain into terminal. I was hoping to be able execute an applescript which changed the HD spindown time when I changed location. I can open terminal and set the command:

sudo pmset -b disksleep 5

but then it asks me for my password. I could do my password as keystrokes but I'd prefer to access a password stored in the keychain.

I'm guessing I need to:

set thePW to the password of first key of current keychain whose name is "AdminPassword"

but then convert thePW to keystokes?

cheers



[ Reply to This | # ]
Lock and unlock a Mac using Bluetooth detection
Authored by: everkleer80 on Jan 05, '10 01:01:55PM

I think you want something like this:

do shell script "..." user name theUser password thePW with administrator privileges
(I think that's the correct syntax)

This way you do not need to say sudo in your script; all commands in the script will be run with full admin priveleges.

[ Reply to This | # ]
Lock and unlock a Mac using Bluetooth detection
Authored by: puzzlebobble on Jan 05, '10 01:06:38PM

cool, I must have been typing at the same time as you. I'll give that way a go. thanks!



[ Reply to This | # ]
Lock and unlock a Mac using Bluetooth detection
Authored by: puzzlebobble on Jan 05, '10 01:04:15PM

think I got it:

tell application "Keychain Scripting"
set thePW to the password of first key of current keychain whose name is "AdminPassword"
delay 1
try
do shell script "sudo pmset -a disksleep 15" password thePW with administrator privileges
on error
display dialog "Oops. Wrong password?"
end try
end tell

sets all setting for spindown to 15 minutes. Now to have different for battery power etc...



[ Reply to This | # ]
Lock and unlock a Mac using Bluetooth detection
Authored by: everkleer80 on Jan 06, '10 06:09:29AM

Cool. I don't think you need "sudo", as the "with administrator privileges" gives the script the same rights as sudo. I read here that using both can create some kind of security hole, though I'm not sure how and the article doesn't explain.



[ Reply to This | # ]