Last active
October 4, 2019 04:12
-
-
Save akshaykarnawat/e01d040fb9283f1f8e4063e8220a283c to your computer and use it in GitHub Desktop.
Eye Care 20-20-20 rule
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
from os import popen, system | |
from time import sleep | |
# Note: this requires brightness package to be installed from homebrew | |
# https://brew.sh | |
# brew update; brew upgrade; brew install brightness | |
# #future -- rewite as shell script..no need for py | |
CURRENT_BRIGHTNESS = 1 | |
def _set_current_brightness(): | |
CURRENT_BRIGHTNESS = popen("brightness -l | grep brightness | awk -F' ' '{print $4}'").read().replace('\n', '') | |
def full_dim(): | |
system('brightness 0') | |
def un_dim(): | |
system('brightness %s' % CURRENT_BRIGHTNESS) | |
def say(msg): | |
system('say %s' % msg) | |
def timer_count(seconds): | |
timer = 0 | |
while(timer <= seconds): | |
say(timer) | |
timer += 1 | |
def main(): | |
while (True): | |
# go to seep for 20 min | |
say('Setting the timer for 20 min') | |
sleep(20*60) | |
# begin the counter for 20 seconds | |
_set_current_brightness() | |
full_dim() | |
say('Look away for 20 seconds at an object that is 20 feet away') | |
timer_count(20) | |
un_dim() | |
if __name__ == "__main__": | |
say('Running eyecare services') | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment