Skip to content

Instantly share code, notes, and snippets.

@Glench
Created April 26, 2019 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Glench/37e2d16e88c351b7f3da8a9e2a771001 to your computer and use it in GitHub Desktop.
Save Glench/37e2d16e88c351b7f3da8a9e2a771001 to your computer and use it in GitHub Desktop.
A meditation reminder app when I'm using the computer
# 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