Skip to content

Instantly share code, notes, and snippets.

@ruyaoyao
Forked from hiilppp/entering_range.scpt
Created February 8, 2018 03:36
Show Gist options
  • Save ruyaoyao/f95d9dde973a573c1635812f32152db0 to your computer and use it in GitHub Desktop.
Save ruyaoyao/f95d9dde973a573c1635812f32152db0 to your computer and use it in GitHub Desktop.
AppleScript to unlock your Mac's screen. (Use EventScripts to automatically trigger script when a Bluetooth device (e.g., your iPhone) enters your Mac's range: http://www.mousedown.net/mouseware/EventScripts.html)
-- You need to create a Keychain item whose name matches what you use in place
-- of "[keychain_item_name]" on line #7 (and whose password is identical to your
-- user account's password).
tell application "System Events"
if ((get name of every process) contains "ScreenSaverEngine") then
set pw to (do shell script "security find-generic-password -l \"[keychain_item_name]\" -w")
tell application "ScreenSaverEngine" to quit
delay 0.5
keystroke pw
keystroke return
-- set require password to wake of security preferences to false
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment