From db7321af115a79b63267cb18889cbd334e8ca6e2 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 6 Dec 2023 20:58:18 +0100 Subject: scripts: Move many a script from sh to andy --- .local/bin/timer | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to '.local/bin/timer') 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 +} -- cgit v1.2.3