summaryrefslogtreecommitdiff
path: root/.local/bin/timer
blob: 4c33fb02772bfa84fa994e1a79a6b536fb1cff88 (plain) (blame)
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
#!/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