aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xxalarm14
1 files changed, 14 insertions, 0 deletions
diff --git a/xalarm b/xalarm
index 157aca1..399e4e6 100755
--- a/xalarm
+++ b/xalarm
@@ -20,6 +20,18 @@ function xalarm_set {
shift
MESSAGE="${*:-Alarm!}"
+ # Suppor for HH:MM format
+ if echo $DELAY | grep -q '[0-9]:[0-9][0-9]'; then
+ NOW="`date +%s`"
+ LATER="`date -d $DELAY +%s`"
+ DELAY="$(($LATER - $NOW))"
+
+ if (($LATER < $NOW)); then
+ echo "$BASENAME: deadline must be later than now"
+ exit 1
+ fi
+ fi
+
# AT(1) implementation
# Example run: xalarm 1minute mymessage
#echo "xmessage $MESSAGE" | at now +$DELAY
@@ -122,6 +134,8 @@ function xalarm_reset_loop {
# Usage
function xalarm_usage {
echo "usage: $BASENAME [list|cancel|kill|resume|continue|help|usage|loop|reset|reset-loop] [timedef] [message]"
+ echo ""
+ echo "timedef: accepts both sleep(1) and date(1) formats"
exit 1
}