"reminders": touch stamp file only when reminders were shown
[OhMyZshExtensions.git] / plugins / reminders / reminders.plugin.zsh
1 # reminders.plugin.zsh
2 # 2015-05-26, alex@barton.de
3
4 # Show reminders (once every 60 minutes)
5 if [ -z `find ~/.last_reminder -mmin -60 2>/dev/null` ]; then
6         if [ "$(type icalBuddy 2>/dev/null)" -a "$LOGNAME" != "root" ]; then
7                 # icalBuddy(1)
8                 case "$LANG" in
9                         *.UTF*) bul="•"; bul_imp="!"; sep="»"; ;;
10                         *)      bul="*"; bul_imp="!"; sep=">"; ;;
11                 esac
12                 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
13                         -nc -npn -iep "title,due" -stda \
14                         tasksDueBefore:today 2>/dev/null
15                 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
16                         -nc -npn -iep "title,datetime" \
17                         eventsToday+1 2>/dev/null
18                 [ $? -eq 0 ] && echo
19                 unset bul bul_imp sep
20                 [ -w ~/ ] && touch ~/.last_reminder
21         elif [ "$(type remind 2>/dev/null)" -a -r ~/.remind ]; then
22                 # remind(1)
23                 remind -h -g -t5 ~/.remind | \
24                         grep -v '^Reminders for ' | grep -v '^$'
25                 [ $? -eq 0 ] && echo
26                 [ -w ~/ ] && touch ~/.last_reminder
27         fi
28 fi