diff options
Diffstat (limited to 'dotfiles/.config/calcurse/hooks/pre-load')
| -rwxr-xr-x | dotfiles/.config/calcurse/hooks/pre-load | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/dotfiles/.config/calcurse/hooks/pre-load b/dotfiles/.config/calcurse/hooks/pre-load new file mode 100755 index 0000000..20787fe --- /dev/null +++ b/dotfiles/.config/calcurse/hooks/pre-load @@ -0,0 +1,28 @@ +#!/bin/sh + +[ -d "$HOME/.calcurse" ] && data_dir="$HOME/.calcurse" || data_dir="${XDG_DATA_HOME:-$HOME/.local/share}/calcurse" + +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')" + notify-send "📅 Calcurse" "Loading and syncing with caldav server..." + echo "$date Running calcurse-caldav from the pre-load hook..." + timeout 60 calcurse-caldav + rc=$? + if [ $rc -eq 124 ]; then + notify-send "📅 Calcurse" "❌ Syncing timed out" + elif [ $rc -gt 0 ]; then + notify-send "📅 Calcurse" "❌ Syncing failed (see logs)" + else + notify-send "📅 Calcurse" "Calendar synced" + fi + echo + rm caldav/lock + ) >>caldav/log 2>&1 +fi |
