Auto Screen Lock on MacOSX
Reading this community as a mere mortal non-registered reader, I came across this article , which simply forced me to get an invite and register. In this topic, a lot of options were proposed for locking the screen with minimal user participation, but all of them, in my opinion, are somewhat "heavy". In each of the methods it was necessary to press something, click somewhere, and laziness, as you know, conquers the world (in a good way).
So, I would like to introduce to your eyes one of the ways to bring everything to automatism.
From what we prepare:
1) The Xcode package must be installed, for normal use of scripts
2) The BluePhoneElite program, which has a bunch of built-in triggers (iTunes, DVD, change of iChat status, etc.)
3) A mobile phone with Bluetooth (I hope everyone has it? :)) so that you don’t click anywhere.
4) Keychain;)
How to cook:
1) Let's start with a simple one - by 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 will have any questions.
2) Open Programs - Utilities - Keychain and create an object with the name BluePhone with your username and password. (needed for automatic password entry)
3) Open the System - Security settings and check the box "Require password when exiting sleep mode and screensaver."
4) We open AppleScript and here all fun begins :). We copy the following script there: Save it in our user folder (optional). 5) We assign the reaction trigger “Enter / Exit Range” Applescript and specify the file with the script. 6) Go to Settings - Universal Access and check the box “Enable access for assistive devices”. Done! Now, as soon as we move away from the computer with the phone, the screen saver turns on, the movie, music and so on stops, and as soon as we appear near the computer, the script will automatically enter a password for you and put the screen on screen :) I hope that this post will help solve this inconvenience when locking the screen . PS: Do not kick hard - my first record. :)
So, I would like to introduce to your eyes one of the ways to bring everything to automatism.
From what we prepare:
1) The Xcode package must be installed, for normal use of scripts
2) The BluePhoneElite program, which has a bunch of built-in triggers (iTunes, DVD, change of iChat status, etc.)
3) A mobile phone with Bluetooth (I hope everyone has it? :)) so that you don’t click anywhere.
4) Keychain;)
How to cook:
1) Let's start with a simple one - by 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 will have any questions.
2) Open Programs - Utilities - Keychain and create an object with the name BluePhone with your username and password. (needed for automatic password entry)
3) Open the System - Security settings and check the box "Require password when exiting sleep mode and screensaver."
4) We open AppleScript and here all fun begins :). We copy the following script there: Save it in our user folder (optional). 5) We assign the reaction trigger “Enter / Exit Range” Applescript and specify the file with the script. 6) Go to Settings - Universal Access and check the box “Enable access for assistive devices”. Done! Now, as soon as we move away from the computer with the phone, the screen saver turns on, the movie, music and so on stops, and as soon as we appear near the computer, the script will automatically enter a password for you and put the screen on screen :) I hope that this post will help solve this inconvenience when locking the screen . PS: Do not kick hard - my first record. :)
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