Skip to content

Instantly share code, notes, and snippets.

@yangsibai
Forked from hiilppp/entering_range.scpt
Created April 28, 2018 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yangsibai/8671f71d552716761c22eb19532b4055 to your computer and use it in GitHub Desktop.
Save yangsibai/8671f71d552716761c22eb19532b4055 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