less error outpouts if no appointment
This commit is contained in:
parent
66d3669b51
commit
7aa8c71d49
@ -2,16 +2,19 @@
|
|||||||
#Print the next appointment for the day for statusbar
|
#Print the next appointment for the day for statusbar
|
||||||
#or generate notification for upcoming appointment
|
#or generate notification for upcoming appointment
|
||||||
diff=$(calcurse --next | tail -n1 | sed 's/^\s*//; s/\[//;s/\]//' | cut -f1 -d ' ')
|
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 ))
|
if [ -n "$diff" ]; then
|
||||||
time_appointment="$(date --date "@$(( $( date +'%s' ) + $secs ))" +"%s")"
|
secs=$(( $(echo "$diff" | cut -f1 -d ':') * 3600 + $(echo "$diff" | cut -f2 -d ':') *60 ))
|
||||||
appointment="$(calcurse --next | tail -n1 | awk '{$1=""; print $0}' | sed 's/^\s*//')"
|
time_appointment="$(date --date "@$(( $( date +'%s' ) + $secs ))" +"%s")"
|
||||||
if [ "$1" = "notif" ]; then
|
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")"
|
msg="$(printf '%s\n%s' "$(date --date "@$time_appointment" +'%H:%M')" "$appointment")"
|
||||||
notify-send "Appointment coming up" "$msg"
|
notify-send "Appointment coming up" "$msg"
|
||||||
else
|
else
|
||||||
midnight=$(( $(date --date "$(date | sed 's/..:..:../23:59:59/; s/ PM//; s/ AM//')" +%s) + 1 ))
|
midnight=$(( $(date --date "$(date | sed 's/..:..:../23:59:59/; s/ PM//; s/ AM//')" +%s) + 1 ))
|
||||||
if [ $midnight -gt "$time_appointment" ]; then
|
if [ $midnight -gt "$time_appointment" ]; then
|
||||||
printf '%s %s' "$(date --date "@$time_appointment" +'%H:%M')" "$appointment"
|
printf '%s %s' "$(date --date "@$time_appointment" +'%H:%M')" "$appointment"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
printf '\n'
|
printf '\n'
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user