Reading this community as a mere
mortal, unregistered reader came across this
article , which simply forced me to get an invite and register. In this topic, it was proposed a lot of screen lock options with minimal user participation, but all of them, in my opinion, are somewhat “heavy”. In each of the ways it was necessary to press something, to click somewhere, and laziness, as you know, wins the world (in a good way).
So, I would like to present your eyes one of the ways to bring everything to automatism.
What we are preparing:
1) The Xcode package must be installed for normal use of scripts.
2)
BluePhoneElite program, which has a bunch of built-in triggers (Itunes, DVD, iChat status changes, etc.)
3) A mobile phone with Bluetooth (I hope everyone has? :)) in order not to click anywhere.
4) Keychain;)
')
How to cook:
1) Let's start with a simple one - with installing BluePhoneElite on a computer. The program is paid, but worth the money (IMHO). How to put the program and "pair" with the phone I think no one questions will arise.
2) Open Programs - Utilities - Keychain (Keychain) and create an object with the name BluePhone with your username and password. (needed for automatic password entry)
3) Open the System Settings - Security and set the checkbox "Require a password when exiting sleep mode and splash screen".
4) Open AppleScript and here all the fun begins :). Copy the following script there:
using terms from application "BluePhoneElite 2"
on proximity change phone with event theEvent
if theEvent is "exited" then
set the target_app to ((path to "dlib" from system domain as string) & ¬
"Frameworks:ScreenSaver.framework:Versions:A:Resources:ScreenSaverEngine.app") as alias
set process_flag to false
tell application "System Events"
if exists process "ScreenSaverEngine" then set process_flag to true
if (application processes whose name is "SecurityAgent") is not {} then
if windows of process "SecurityAgent" is not {} then set the process_flag to true
end if
end tell
if process_flag is false then tell application (target_app as string) to launch
end if
if theEvent is "entered" then
set the process_flag to false
tell application "System Events"
if exists process "ScreenSaverEngine" then
set the process_flag to true
tell application "System Events" to keystroke return
else
if (application processes whose name is "SecurityAgent") is not {} then
if windows of process "SecurityAgent" is not {} then set the process_flag to true
end if
end if
end tell
if the process_flag is false then return
set now to current date
repeat
tell application "System Events"
if (application processes whose name is "SecurityAgent") is not {} then
if (windows of process "SecurityAgent") is not {} then
tell application "Keychain Scripting"
set MP to password of key 1 of keychain ¬
"login.keychain" whose name is "BluePhone"
end tell
tell window 1 of application process "SecurityAgent"
keystroke MP
click button "OK" of group 2
end tell
return
end if
end if
end tell
if ((current date) - now) is greater than 20 then exit repeat
delay 0.2
end repeat
end if
end proximity change
end using terms from
Save it in your user folder (optional).
5) Appoint the trigger of the “Enter / Exit Range” reaction in Applescript and specify the file with the script.
6) Go to Settings - Universal access and put a tick "Enable access for assistive devices."
Done!
Now, as soon as we move away from the computer along with the phone, the screen saver turns on, the movie, music, etc. stops, and as soon as we appear near the computer, the script will automatically enter the password for you and pop the screen :)
I hope that this post will help solve this inconvenience when locking the screen.
PS: Not to kick hard - my first entry. :)