]> arthur.barton.de Git - ax-zsh.git/blob - plugins/icalbuddy/icalbuddy.ax-io
7c6c6c36b4925a3420f093b59ead90482ac3271b
[ax-zsh.git] / plugins / icalbuddy / icalbuddy.ax-io
1 # AX-ZSH: Alex' Modular ZSH Configuration
2 # icalbuddy.zshrc: Show reminders using icalBuddy(1).
3
4 # Make sure that "icalBuddy(1)" is installed.
5 (( $+commands[icalBuddy] )) || return 1
6
7 # Don't run this plugin on "check-plugins"!
8 [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 0
9
10 # Don't show reminders when ~/.hushlogin exists ...
11 [[ -r ~/.hushlogin ]] && return 0
12
13 # Check if reminders have been shown during last 60 minutes, and if so,
14 # don't show them now but return.
15 [[ -z `find "$XDG_CACHE_HOME/axzsh_last_reminder" -mmin -60 2>/dev/null` ]] || return 0
16
17 tmpfile=$(mktemp ${TMPDIR:-/tmp}/icalbuddy.XXXXXX) || return 1
18
19 if [[ "$LANG" =~ "\.UTF" ]]; then
20         bul="•"; bul_imp="!"; sep="»"
21 else
22         bul="*"; bul_imp="!"; sep=">"
23 fi
24
25 # Show reminders now.
26 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
27         -nc -npn -iep "title,due" -stda \
28         tasksDueBefore:today 2>/dev/null >>"$tmpfile"
29 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
30         -nc -npn -iep "title,datetime" \
31         eventsToday+1 2>/dev/null >>"$tmpfile"
32
33 if [[ -s "$tmpfile" ]]; then
34         cat "$tmpfile"; echo
35 fi
36
37 rm -f "$tmpfile"
38 unset bul bul_imp sep tmpfile
39
40 # Wtite "stamp" file.
41 [[ -w ~/ ]] && touch "$XDG_CACHE_HOME/axzsh_last_reminder"