+alarm script in python for hour-based alarms via notify-send

This commit is contained in:
dx
2020-07-09 22:11:02 +01:00
parent 617dbb982e
commit ecf78066b3

26
Scripts/.local/scripts/alarm Executable file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env python
from time import time, sleep
from sys import argv
from subprocess import run
name = "Alarm"
duration = 1
if (len(argv) > 1):
duration = float(argv[1])
if (len(argv) > 2):
name = argv[2]
duration *= 3600
print("Starting alarm '%s'" % name, "of duration %ds" % duration)
current = time()
end = current + duration
while (time() <= end):
sleep(1)
run(["notify-send", f"Alarm {name} complete"])