aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2022-06-04 17:27:10 -0300
committerSilvio Rhatto <rhatto@riseup.net>2022-06-04 17:27:10 -0300
commit10bd517b3889405a1ec836d5416f421b285ebbed (patch)
treefe1b160db71d43885a1fd1b52b49be4ef92475ff
parenta1c6214cb1eb549a34b6167defa1ee9f9c5d3b25 (diff)
downloadutils-x11-10bd517b3889405a1ec836d5416f421b285ebbed.tar.gz
utils-x11-10bd517b3889405a1ec836d5416f421b285ebbed.tar.bz2
Feat: utils-x11: timedef: accepts both sleep(1) and date(1) formats
-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
}