some cosmetic changes for eyewatch.py
This commit is contained in:
parent
e796df39fc
commit
06dca61343
1 changed files with 7 additions and 2 deletions
|
@ -17,6 +17,7 @@ MESSAGES = (
|
||||||
'move your eyes sideways'
|
'move your eyes sideways'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def parse_args(sys_args):
|
def parse_args(sys_args):
|
||||||
desc = 'display a reminder to take a short break and do some eye practice'
|
desc = 'display a reminder to take a short break and do some eye practice'
|
||||||
p = ArgumentParser(description=desc)
|
p = ArgumentParser(description=desc)
|
||||||
|
@ -24,7 +25,8 @@ def parse_args(sys_args):
|
||||||
'-t',
|
'-t',
|
||||||
'--timer',
|
'--timer',
|
||||||
default='600',
|
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(
|
p.add_argument(
|
||||||
'-o',
|
'-o',
|
||||||
|
@ -40,11 +42,13 @@ def parse_args(sys_args):
|
||||||
)
|
)
|
||||||
return p.parse_args(sys_args)
|
return p.parse_args(sys_args)
|
||||||
|
|
||||||
|
|
||||||
def get_random_message(message_list):
|
def get_random_message(message_list):
|
||||||
list_len = len(message_list)
|
list_len = len(message_list)
|
||||||
random_value = randint(0, list_len - 1)
|
random_value = randint(0, list_len - 1)
|
||||||
return message_list[random_value]
|
return message_list[random_value]
|
||||||
|
|
||||||
|
|
||||||
def show_notification(notification, icon):
|
def show_notification(notification, icon):
|
||||||
text = get_random_message(MESSAGES)
|
text = get_random_message(MESSAGES)
|
||||||
print('[' + strftime('%H:%M:%S') + '] ' + text)
|
print('[' + strftime('%H:%M:%S') + '] ' + text)
|
||||||
|
@ -55,12 +59,13 @@ def show_notification(notification, icon):
|
||||||
notification.set_urgency(URGENCY)
|
notification.set_urgency(URGENCY)
|
||||||
notification.show()
|
notification.show()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
args = parse_args(argv[1:])
|
args = parse_args(argv[1:])
|
||||||
Notify.init(argv[0])
|
Notify.init(argv[0])
|
||||||
notification = Notify.Notification.new(summary=TITLE)
|
notification = Notify.Notification.new(summary=TITLE)
|
||||||
|
|
||||||
if args.once == True:
|
if args.once:
|
||||||
show_notification(notification, args.icon)
|
show_notification(notification, args.icon)
|
||||||
else:
|
else:
|
||||||
while True:
|
while True:
|
||||||
|
|
Loading…
Reference in a new issue