]> arthur.barton.de Git - ax-zsh.git/commitdiff
New "calendar" plugin
authorAlexander Barton <alex@barton.de>
Fri, 31 Jul 2020 17:08:56 +0000 (19:08 +0200)
committerAlexander Barton <alex@barton.de>
Fri, 31 Jul 2020 17:08:56 +0000 (19:08 +0200)
plugins/calendar/README.md [new file with mode: 0644]
plugins/calendar/calendar.ax-io [new file with mode: 0644]

diff --git a/plugins/calendar/README.md b/plugins/calendar/README.md
new file mode 100644 (file)
index 0000000..3979b85
--- /dev/null
@@ -0,0 +1,4 @@
+## calendar
+
+Show calendar(1) entries for the current day, but not more often than once
+every hour.
diff --git a/plugins/calendar/calendar.ax-io b/plugins/calendar/calendar.ax-io
new file mode 100644 (file)
index 0000000..1013200
--- /dev/null
@@ -0,0 +1,26 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# calendar.ax-io: Show calendar(1) entries for the current day.
+
+# Make sure that "calendar(1)" is installed.
+(( $+commands[calendar] )) || return 1
+
+# Don't run this plugin on "check-plugins"!
+[[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 0
+
+# Don't show any info when ~/.hushlogin exists ...
+[[ -r ~/.hushlogin ]] && return 0
+
+# Check if neofetch(1) infos have been shown during last 60 minutes, and if so,
+# don't show them now but return.
+[[ -z `find "$XDG_CACHE_HOME/axzsh_last_calendar" -mmin -60 2>/dev/null` ]] || return 0
+
+tmpfile=$(mktemp ${TMPDIR:-/tmp}/calendar.XXXXXX) || return 1
+
+calendar -A0 >"$tmpfile"
+if [[ -s "$tmpfile" ]]; then
+       cat "$tmpfile"; echo
+fi
+rm -f "$tmpfile"
+
+# Wtite "stamp" file.
+[[ -w ~/ ]] && touch "$XDG_CACHE_HOME/axzsh_last_calendar"