commit d9360c46d49f031bf15db2a09c84fece4462a136 parent f977c39f915d78f71ec018726b3f58bf8fe031f4 Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Wed, 6 May 2020 09:59:36 +0200 Fix parsing of 1-digit hour formats and past events, increase urgency of notifications Diffstat:
M | .local/bin/calendar-notify | | | 10 | +++++++--- |
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/.local/bin/calendar-notify b/.local/bin/calendar-notify @@ -19,13 +19,17 @@ calendar -A 0 | while read -r month day time desc; do time="" fi - if [ -n "$time" ]; then + if [ -n "${time}" ]; then hour="$(printf '%s' "$time" | sed 's/\([0-2]*[0-9]\):.*/\1/')" + if [ "$(printf '%s' "$hour" | wc -c)" -lt 2 ]; then + hour="0${hour}" + fi min="$(printf '%s' "$time" | sed 's/[0-2]*[0-9]:\([0-5][0-9]\).*/\1/')" t="$(date -j +%s "$(date +%Y%m)${day}${hour}${min}")" - if [ $(( $t - $t_now )) -le "$t_notify" ]; then - notify-send "${desc}" "${time}" + dt="$(( $t - $t_now ))" + if [ "$dt" -le "$t_notify" ] && [ "$dt" -ge 0 ]; then + notify-send -u critical "$desc" "$time" fi fi done