-
Notifications
You must be signed in to change notification settings - Fork 0
/
pomodoro
executable file
·52 lines (40 loc) · 1.03 KB
/
pomodoro
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
#!/usr/bin/env python3
import signal
import sys
import os
from subprocess import run
def abort(signal, frame):
run(["notify-send", "-i", "edit-delete", "Timer aborted"])
cleanExit()
def cleanExit():
try:
os.remove(lockFile)
except:
pass
sys.exit(0)
lockFile = "/tmp/atmoz-pomodoro.lock"
existing_pid = 0
try:
with open(lockFile, "r") as f:
existing_pid = f.read()
f.closed
except:
pass
if existing_pid == 0:
with open(lockFile, "w") as f:
f.write(str(os.getpid()))
f.closed
else:
print("killing '" + existing_pid + "'")
run(["kill", existing_pid])
cleanExit()
signal.signal(signal.SIGQUIT, abort)
signal.signal(signal.SIGINT, abort)
signal.signal(signal.SIGTERM, abort)
run(["notify-send", "-i", "appointment-new", "Timer started"])
run(["timeline", "25", "m", "dec"])
run(["notify-send", "-i", "starred", "-t", str(5000 * 60),
"Time over!", "You can now take a break"])
run(["timeline", "5", "m", "inc"])
run(["notify-send", "Break is over"])
cleanExit()