-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimew
executable file
·71 lines (58 loc) · 1.8 KB
/
timew
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/python3
import os
import easygui
import subprocess
from tasklib import TaskWarrior
def start():
w = TaskWarrior()
tasks = w.tasks.pending()
tasks_r = []
for task in tasks:
tasks_r.append(str(task['id']) + ": " +task['project'] + ": " +task['description'])
msg="What task will you be working on?"
title="task"
myvar = None
if len(tasks_r) !=0:
if len(tasks_r) ==1: # easygui choicebox want at least two options
tasks_r.append("")
#FIX: why is that font so weird?
myvar = easygui.choicebox(msg, title, tasks_r)
if (myvar != None and myvar != "Add more choices"):
os.system("task start " + str(myvar).split(':')[0] +"")
if (myvar == None or myvar == "Add more choices"):
myvar = easygui.enterbox(msg, title)
if (myvar != None):
os.system('timew start ' + myvar +' > /dev/null')
def stop():
w = TaskWarrior()
tasks = w.tasks.pending()
for task in tasks:
os.system('task stop ' + str(task['id']))
os.system('timew stop')
def left_click():
start()
def right_click():
stop()
#Personnaly I don't use middle click
def middle_click():
pass
def get_status():
status = subprocess.run('timew', capture_output=True)
if status.stdout==b"There is no active time tracking.\n":
print('')
else:
out = ' '
for e in status.stdout.splitlines()[0].split()[1:]:
out += e.decode('utf-8') + " "
out += "- " + status.stdout.splitlines()[3].split()[1].decode('utf-8')
print(out)
def main():
if os.environ.get('BLOCK_BUTTON') == "1":
left_click()
if os.environ.get('BLOCK_BUTTON') == "2":
middle_click()
if os.environ.get('BLOCK_BUTTON') == "3":
right_click()
get_status()
if __name__ == "__main__":
main()