diff options
Diffstat (limited to 'dotfiles/.config/calcurse/hooks/post-save')
| -rwxr-xr-x | dotfiles/.config/calcurse/hooks/post-save | 33 | 
1 files changed, 33 insertions, 0 deletions
diff --git a/dotfiles/.config/calcurse/hooks/post-save b/dotfiles/.config/calcurse/hooks/post-save new file mode 100755 index 0000000..ead4a47 --- /dev/null +++ b/dotfiles/.config/calcurse/hooks/post-save @@ -0,0 +1,33 @@ +#!/bin/sh +# +# This is an example hook. It does two things whenever you save the data files: +# +# Synchronize with a CalDAV server if calcurse-caldav is configured. +# +# In order to install this hook, copy this file to +# $XDG_CONFIG_HOME/calcurse/hooks/ (~/.config/calcurse/hooks/) or +# ~/.calcurse/hooks/ if using ~/.calcurse. + +data_dir="$HOME/.calcurse" +config_dir="$HOME/.calcurse" + +if [ ! -d "$data_dir" ]; then +	data_dir="${XDG_DATA_HOME:-$HOME/.local/share}/calcurse" +	config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/calcurse" +fi + +cd "$data_dir" || exit + +# Do not do anything when synchronizing with a CalDAV server. +[ -f caldav/lock ] && exit + +# Run the CalDAV synchronization script. +if [ -d caldav ] && command -v calcurse-caldav >/dev/null; then +	( +		date="$(date +'%b %d %H:%M:%S')" +		echo "$date Running calcurse-caldav from the post-save hook..." +		calcurse-caldav +		echo +		rm caldav/lock +	) >>caldav/log 2>&1 +fi  | 
