From 06dca61343f0cbdd5c48c8bdede645c89e27d536 Mon Sep 17 00:00:00 2001 From: Von Random Date: Wed, 10 May 2017 15:33:10 +0300 Subject: [PATCH] some cosmetic changes for eyewatch.py --- eyewatch.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/eyewatch.py b/eyewatch.py index f2ecb0a..d26f2a4 100755 --- a/eyewatch.py +++ b/eyewatch.py @@ -17,6 +17,7 @@ MESSAGES = ( 'move your eyes sideways' ) + def parse_args(sys_args): desc = 'display a reminder to take a short break and do some eye practice' p = ArgumentParser(description=desc) @@ -24,7 +25,8 @@ def parse_args(sys_args): '-t', '--timer', default='600', - help='run in foreground, showing notification every TIMER seconds (this is default, with TIMER = 300)' + help=('run in foreground, showing notification every TIMER seconds ' + '(this is default, with TIMER = 600)') ) p.add_argument( '-o', @@ -40,11 +42,13 @@ def parse_args(sys_args): ) return p.parse_args(sys_args) + def get_random_message(message_list): list_len = len(message_list) random_value = randint(0, list_len - 1) return message_list[random_value] + def show_notification(notification, icon): text = get_random_message(MESSAGES) print('[' + strftime('%H:%M:%S') + '] ' + text) @@ -55,12 +59,13 @@ def show_notification(notification, icon): notification.set_urgency(URGENCY) notification.show() + if __name__ == '__main__': args = parse_args(argv[1:]) Notify.init(argv[0]) notification = Notify.Notification.new(summary=TITLE) - if args.once == True: + if args.once: show_notification(notification, args.icon) else: while True: