summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-12-04 17:08:09 +0100
committerThomas Voss <mail@thomasvoss.com> 2023-12-04 17:08:09 +0100
commit880074a2690ed1f1a6f28ebb2f403cc264f65c62 (patch)
tree17a1a3eb8d3f467e12c10db0034f346283416e92
parent02241e4f8b7de21ef90237a8ca60e904c5e034cf (diff)
timer: Add script for setting notifying timers
-rwxr-xr-x.local/bin/timer28
1 files changed, 28 insertions, 0 deletions
diff --git a/.local/bin/timer b/.local/bin/timer
new file mode 100755
index 0000000..4c33fb0
--- /dev/null
+++ b/.local/bin/timer
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+set -e
+
+abort()
+{
+ notify 'Timer Interrupted' 'The timer was unexpectedly interrupted' \
+ -u critical
+ exit 1
+}
+
+export NOTIFY_LONG=timer
+export NOTIFY_SHORT=${0##*/}
+
+if [ $# -eq 0 ]
+then
+ echo 'Usage: timer duration [message]' >&2
+ exit 1
+fi
+
+trap abort HUP INT QUIT ABRT KILL ALRM TERM
+
+if sleep "$1"
+then
+ notify 'Timer Finished' "$2"
+else
+ abort
+fi