summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/caldav/hooks/post-sync17
-rwxr-xr-xcontrib/hooks/post-save29
-rwxr-xr-xcontrib/hooks/pre-load21
3 files changed, 55 insertions, 12 deletions
diff --git a/contrib/caldav/hooks/post-sync b/contrib/caldav/hooks/post-sync
index c119ba7..1ac028c 100755
--- a/contrib/caldav/hooks/post-sync
+++ b/contrib/caldav/hooks/post-sync
@@ -1,12 +1,17 @@
#!/bin/sh
#
-# Copy this file into ~/.calcurse/caldav/hooks/ and mark it executable to
-# automatically commit changes after syncing using Git.
+# This is an example hook. If the calcurse data directory contains a Git
+# repository, it automatically makes a commit whenever synchronizing with a
+# CalDAV server.
+#
+# In order to install this hook, copy this file to ~/.calcurse/caldav/hooks/.
cd "$HOME"/.calcurse/
-git add apts conf keys todo
-if ! git diff-index --quiet --cached HEAD; then
- git commit -m "Automatic commit by the post-sync hook"
+# If the data directory is under version control, create a Git commit.
+if [ -d .git -a -x "$(which git)" ]; then
+ git add apts conf keys todo
+ if ! git diff-index --quiet --cached HEAD; then
+ git commit -m "Automatic commit by the post-sync hook"
+ fi
fi
-
diff --git a/contrib/hooks/post-save b/contrib/hooks/post-save
index 574a721..bb582e2 100755
--- a/contrib/hooks/post-save
+++ b/contrib/hooks/post-save
@@ -1,14 +1,31 @@
#!/bin/sh
#
-# Copy this file into ~/.calcurse/hooks/ and mark it executable to
-# automatically commit any changes to the calcurse data files using Git.
+# This is an example hook. It does two things whenever you save the data files:
+#
+# 1. Make a commit if the calcurse data directory contains a Git repository.
+# 2. Synchronize with a CalDAV server if calcurse-caldav is configured.
+#
+# In order to install this hook, copy this file to ~/.calcurse/hooks/.
cd "$HOME"/.calcurse/
-# Do not make commits when synchronizing with a CalDAV server.
+# Do not do anything when synchronizing with a CalDAV server.
[ -f caldav/lock ] && exit
-git add apts conf keys todo
-if ! git diff-index --quiet --cached HEAD; then
- git commit -m "Automatic commit by the post-save hook"
+# If the data directory is under version control, create a Git commit.
+if [ -d .git -a -x "$(which git)" ]; then
+ git add apts conf keys todo
+ if ! git diff-index --quiet --cached HEAD; then
+ git commit -m "Automatic commit by the post-save hook"
+ fi
+fi
+
+# Optionally 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 post-save hook..."
+ calcurse-caldav
+ echo
+ ) >>caldav/log 2>&1 &
fi
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