summaryrefslogtreecommitdiff
path: root/.local/bin/timer
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-12-06 20:58:18 +0100
committerThomas Voss <mail@thomasvoss.com> 2023-12-06 20:58:47 +0100
commitdb7321af115a79b63267cb18889cbd334e8ca6e2 (patch)
treeec388295051ebc1f3d79bd3baf79b7f12f076cda /.local/bin/timer
parentf2fde1570a04a654e2ed0c165d56feb29ddb25bf (diff)
scripts: Move many a script from sh to andy
Diffstat (limited to '.local/bin/timer')
-rwxr-xr-x.local/bin/timer42
1 files changed, 20 insertions, 22 deletions
diff --git a/.local/bin/timer b/.local/bin/timer
index 4c33fb0..fc2652f 100755
--- a/.local/bin/timer
+++ b/.local/bin/timer
@@ -1,28 +1,26 @@
-#!/bin/sh
+#!/usr/local/bin/andy
-set -e
-
-abort()
-{
- notify 'Timer Interrupted' 'The timer was unexpectedly interrupted' \
- -u critical
- exit 1
+for sig in hup int quit abrt kill alrm term {
+ func sig$sig {
+ notify (
+ 'Timer Interrupted'
+ 'The timer was unexpectedly interrupted'
+ -u critical
+ )
+ exit 1
+ }
}
-export NOTIFY_LONG=timer
-export NOTIFY_SHORT=${0##*/}
+set -e NOTIFY_LONG timer
+set -e NOTIFY_SHORT `basename $args[0]
-if [ $# -eq 0 ]
-then
- echo 'Usage: timer duration [message]' >&2
+if test $#args -lt 2 {
+ echo 'Usage: timer duration [message]' >/dev/stderr
exit 1
-fi
-
-trap abort HUP INT QUIT ABRT KILL ALRM TERM
+}
-if sleep "$1"
-then
- notify 'Timer Finished' "$2"
-else
- abort
-fi
+if sleep $args[1] {
+ notify 'Timer Finished' $args[2]
+} else {
+ sigint
+}