summaryrefslogtreecommitdiffstats
path: root/contrib/hooks/pre-load
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-02-08 08:01:06 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2016-02-08 08:17:49 +0100
commit4ab6e75aa906ebf85cf68b5f23be003a7dae9c7a (patch)
treea316ccbce61e46b7e87860f27651dbf7822e6764 /contrib/hooks/pre-load
parent616c3759a5f28f3f6229af6d5d7ea0f302cbb17c (diff)
downloadcalcurse-4ab6e75aa906ebf85cf68b5f23be003a7dae9c7a.tar.gz
calcurse-4ab6e75aa906ebf85cf68b5f23be003a7dae9c7a.zip
Improve example hooks
The post-save and post-sync hooks now automatically detect whether the data directory contains a .git/ directory and skip the commit creation process if it does not. The post-save hook and the new pre-load hook now also run calcurse-caldav in the background if that script is available and the data directory contains a caldav/ directory. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'contrib/hooks/pre-load')
-rwxr-xr-xcontrib/hooks/pre-load21
1 files changed, 21 insertions, 0 deletions
diff --git a/contrib/hooks/pre-load b/contrib/hooks/pre-load
new file mode 100755
index 0000000..c9ab62d
--- /dev/null
+++ b/contrib/hooks/pre-load
@@ -0,0 +1,21 @@
+#!/bin/sh
+#
+# This is an example hook. It synchronizes calcurse with a CalDAV server before
+# loading the data files.
+#
+# In order to install this hook, copy this file to ~/.calcurse/hooks/.
+
+cd "$HOME"/.calcurse/
+
+# Do not do anything when synchronizing with a CalDAV server.
+[ -f caldav/lock ] && exit
+
+# Run the CalDAV synchronization script in the background.
+if [ -d caldav -a -x "$(which calcurse-caldav)" ]; then
+ (
+ date="$(date +'%b %d %H:%M:%S')"
+ echo "$date Running calcurse-caldav from the pre-load hook..."
+ calcurse-caldav
+ echo
+ ) >>caldav/log 2>&1 &
+fi