calcurse statusbar and notifications integration

This commit is contained in:
Alexander Bocken 2020-12-14 22:16:11 +01:00
parent ace18f75c3
commit f06976bc1c
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8
2 changed files with 18 additions and 1 deletions

View File

@ -27,6 +27,6 @@ general.multipledays=yes
general.periodicsave=1 general.periodicsave=1
general.systemevents=yes general.systemevents=yes
general.systemdialogs=yes general.systemdialogs=yes
notification.command=printf '\a' notification.command=printf 'appointments notif'
notification.notifyall=all notification.notifyall=all
notification.warning=300 notification.warning=300

View File

@ -0,0 +1,17 @@
#!/bin/bash
#Print the next appointment for the day for statusbar
#or generate notification for upcoming appointment
diff=$(calcurse --next | tail -n1 | sed 's/^\s*//; s/\[//;s/\]//' | cut -f1 -d ' ')
secs=$(( $(echo "$diff" | cut -f1 -d ':') * 3600 + $(echo "$diff" | cut -f2 -d ':') *60 ))
time_appointment="$(date --date "@$(( $( date +'%s' ) + $secs ))" +"%s")"
appointment="$(calcurse --next | tail -n1 | awk '{$1=""; print $0}' | sed 's/^\s*//')"
if [ "$1" = "notif" ]; then
msg="$(printf '%s\n%s' "$(date --date "@$time_appointment" +'%H:%M')" "$appointment")"
notify-send "Appointment coming up" "$msg"
else
midnight=$(( $(date --date "$(date | sed 's/..:..:../23:59:59/; s/ PM//; s/ AM//')" +%s) + 1 ))
if [ $midnight -gt "$time_appointment" ]; then
printf '%s %s' "$(date --date "@$time_appointment" +'%H:%M')" "$appointment"
fi
printf '\n'
fi