Last active
December 13, 2022 20:58
-
-
Save howkymike/e3177713b4990290f2c18e2185ff5612 to your computer and use it in GitHub Desktop.
AppleScript 20-20-20 rule very simple application to protect your eye's vision. Every 20 minutes the app is ringing (then you should look at distant object), and after 20 seconds it rings again (then you can go back to work).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Installation instructions: | |
1. Download this file and open with Script Editor | |
2. Extract screenLockChecker.sh from this file and save in desired location | |
3. Edit PATH_TO_SCREEN_LOCK_CHECKER_SCRIPT to absolute path to the screenLockChecker.sh script | |
4. Go to File -> Export... -> set "File Format" to "Application" and click "Save" | |
5. (Optionally add to startup) Open system Preferences -> Search "Open at Login" -> add newly created app | |
*) | |
-- Author: howkymike 2022 | |
repeat while true | |
delay 60 * 20 | |
set scriptRes to do shell script "<PATH_TO_SCREEN_LOCK_CHECKER_SCRIPT>" | |
if scriptRes is equal to "Screen unlocked" then | |
say "ding dong ding dong ding dong" using "Bells" | |
delay 20 | |
say "return return" using "Bells" | |
end if | |
end repeat | |
(* screenLockChecker.sh, credits: https://stackoverflow.com/a/66723000/5764479 | |
#!/bin/sh | |
function screenIsLocked { [ "$(/usr/libexec/PlistBuddy -c "print :IOConsoleUsers:0:CGSSessionScreenIsLocked" /dev/stdin 2>/dev/null <<< "$(ioreg -n Root -d1 -a)")" = "true" ] && return 0 || return 1; } | |
function screenIsUnlocked { [ "$(/usr/libexec/PlistBuddy -c "print :IOConsoleUsers:0:CGSSessionScreenIsLocked" /dev/stdin 2>/dev/null <<< "$(ioreg -n Root -d1 -a)")" != "true" ] && return 0 || return 1; } | |
if screenIsLocked; then | |
echo "Screen locked" | |
fi | |
if screenIsUnlocked; then | |
echo "Screen unlocked" | |
fi | |
*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment