some cosmetic changes for eyewatch.py

This commit is contained in:
Von Random 2017-05-10 15:33:10 +03:00
parent e796df39fc
commit 06dca61343

View file

@ -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: