Created
April 26, 2019 19:50
-
-
Save Glench/37e2d16e88c351b7f3da8a9e2a771001 to your computer and use it in GitHub Desktop.
A meditation reminder app when I'm using the computer
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
# This Python file uses the following encoding: utf-8 | |
import subprocess | |
import time | |
breathing_time = 30 # seconds | |
interval_between_breathing = 25 * 60 # seconds | |
applescript = """ | |
display dialog "Breathe and make a home of your body" ¬ | |
with title "Breathe" ¬ | |
with icon caution ¬ | |
buttons {"OK"} | |
""" | |
def ding(): | |
subprocess.call("afplay /System/Library/Sounds/Glass.aiff", shell=True) | |
while True: | |
idle_time = int(subprocess.check_output('ioreg -c IOHIDSystem | egrep "HIDIdle" | egrep -o "\d+"', shell=True)) / 1.0e9 # seconds | |
if idle_time < 60: # seconds | |
subprocess.call("osascript -e '{}'".format(applescript), shell=True) | |
ding() | |
time.sleep(breathing_time) | |
ding() | |
time.sleep(interval_between_breathing) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment