diff options
author | dx <aryadevchavali1@gmail.com> | 2020-07-09 22:11:02 +0100 |
---|---|---|
committer | dx <aryadevchavali1@gmail.com> | 2020-07-09 22:11:02 +0100 |
commit | ecf78066b34be5bbfc1082be5b0a7fcd880f006e (patch) | |
tree | 1ba974a7adaafab22eb5b98f9ee1164269308404 /Scripts/.local | |
parent | 617dbb982ed2d634117ebb5e039ccf42257e71bb (diff) | |
download | dotfiles-ecf78066b34be5bbfc1082be5b0a7fcd880f006e.tar.gz dotfiles-ecf78066b34be5bbfc1082be5b0a7fcd880f006e.tar.bz2 dotfiles-ecf78066b34be5bbfc1082be5b0a7fcd880f006e.zip |
+alarm script in python for hour-based alarms via notify-send
Diffstat (limited to 'Scripts/.local')
-rwxr-xr-x | Scripts/.local/scripts/alarm | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Scripts/.local/scripts/alarm b/Scripts/.local/scripts/alarm new file mode 100755 index 0000000..f880679 --- /dev/null +++ b/Scripts/.local/scripts/alarm @@ -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"]) |