]> arthur.barton.de Git - ax-zsh.git/blobdiff - plugins/icalbuddy/icalbuddy.ax-io
Introduce new "ax-io" stage, which is run before all other stages
[ax-zsh.git] / plugins / icalbuddy / icalbuddy.ax-io
diff --git a/plugins/icalbuddy/icalbuddy.ax-io b/plugins/icalbuddy/icalbuddy.ax-io
new file mode 100644 (file)
index 0000000..52849bc
--- /dev/null
@@ -0,0 +1,41 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# icalbuddy.zshrc: Show reminders using icalBuddy(1).
+
+# Make sure that "icalBuddy(1)" is installed.
+(( $+commands[icalBuddy] )) || return 1
+
+# Don't run this plugin on "check-plugins"!
+[[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 0
+
+# Don't show reminders when ~/.hushlogin exists ...
+[[ -r ~/.hushlogin ]] && return 0
+
+# Check if reminders have been shown during last 60 minutes, and if so,
+# don't show them now but return.
+[[ -z `find ~/.last_reminder -mmin -60 2>/dev/null` ]] || return 0
+
+tmpfile=$(mktemp ${TMPDIR:-/tmp}/icalbuddy.XXXXXX) || return 1
+
+if [[ "$LANG" =~ "\.UTF" ]]; then
+       bul="•"; bul_imp="!"; sep="»"
+else
+       bul="*"; bul_imp="!"; sep=">"
+fi
+
+# Show reminders now.
+icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
+       -nc -npn -iep "title,due" -stda \
+       tasksDueBefore:today 2>/dev/null >>"$tmpfile"
+icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
+       -nc -npn -iep "title,datetime" \
+       eventsToday+1 2>/dev/null  >>"$tmpfile"
+
+if [[ -s "$tmpfile" ]]; then
+       echo; cat "$tmpfile"; echo
+fi
+
+rm -f "$tmpfile"
+unset bul bul_imp sep tmpfile
+
+# Wtite "stamp" file.
+[[ -w ~/ ]] && touch ~/.last_reminder