Created
May 8, 2017 20:02
-
-
Save Neoklosch/81b2355ad702a955e2dc776fac415626 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import argparse | |
import os | |
import time | |
import signal | |
import sys | |
import gi | |
gi.require_version('Notify', '0.7') | |
from threading import Timer | |
from gi.repository import Notify | |
def signal_handler(signal, frame): | |
print('no tea today') | |
sys.exit(0) | |
def show_notification(): | |
Notify.Notification.new("It is tea time").show() | |
beep_time = 0.2 | |
frequency = 800 | |
for i in range(7): | |
os.system('play --no-show-progress --null --channels 1 synth %s sine %f' % (beep_time, frequency)) | |
time.sleep(0.3) | |
def main(): | |
signal.signal(signal.SIGINT, signal_handler) | |
Notify.init("Teatimer") | |
parser = argparse.ArgumentParser(description='Process some integers.') | |
parser.add_argument('-s', '--seconds', help='time in seconds', type=int) | |
parser.add_argument('-m', '--minutes', help='time in minutes', type=int) | |
args = parser.parse_args() | |
if args.seconds: | |
time.sleep(args.seconds) | |
show_notification() | |
elif args.minutes: | |
time.sleep(args.minutes * 60) | |
show_notification() | |
else: | |
parser.print_help() | |
sys.exit(0) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment