diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2022-06-04 17:27:10 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2022-06-04 17:27:10 -0300 |
commit | 10bd517b3889405a1ec836d5416f421b285ebbed (patch) | |
tree | fe1b160db71d43885a1fd1b52b49be4ef92475ff | |
parent | a1c6214cb1eb549a34b6167defa1ee9f9c5d3b25 (diff) | |
download | utils-x11-10bd517b3889405a1ec836d5416f421b285ebbed.tar.gz utils-x11-10bd517b3889405a1ec836d5416f421b285ebbed.tar.bz2 |
Feat: utils-x11: timedef: accepts both sleep(1) and date(1) formats
-rwxr-xr-x | xalarm | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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 } |