2020-12-21 09:28:04 +01:00
|
|
|
#!/bin/sh
|
2020-12-14 22:16:11 +01:00
|
|
|
#Print the next appointment for the day for statusbar
|
|
|
|
#or generate notification for upcoming appointment
|
2020-12-24 11:53:05 +01:00
|
|
|
diff=$(calcurse --next | sed -n 's/^\s*//; s/\[//;s/\]//p' | cut -f1 -d ' ' | perl -pe 's/0([0-9])/\1/g' )
|
2020-12-15 14:40:40 +01:00
|
|
|
if [ -n "$diff" ]; then
|
|
|
|
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
|
2020-12-19 11:48:55 +01:00
|
|
|
if [ ! -f /tmp/nodunst ]; then
|
|
|
|
printf '%s %s' "$(date --date "@$time_appointment" +'%H:%M')" "$appointment"
|
|
|
|
fi
|
|
|
|
printf '\n'
|
2020-12-15 14:40:40 +01:00
|
|
|
fi
|
2020-12-14 22:16:11 +01:00
|
|
|
fi
|
2020-12-15 14:40:40 +01:00
|
|
|
else
|
2020-12-14 22:16:11 +01:00
|
|
|
printf '\n'
|
|
|
|
fi
|