diff options
author | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2025-08-31 17:35:56 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2025-08-31 17:35:56 +0300 |
commit | 9bcd7e4a075d91084934be30f1f2d039cf045907 (patch) | |
tree | 7d0bf0f93b881577ed3a2765229c7d13edf8df46 /dotfiles/.config/calcurse/hooks | |
parent | 853bb5bdd92cc18dea87f0bd17ef8fc191cf2f18 (diff) | |
download | swayrice-9bcd7e4a075d91084934be30f1f2d039cf045907.tar.gz swayrice-9bcd7e4a075d91084934be30f1f2d039cf045907.zip |
calcurse: add config and hooksniri
Diffstat (limited to 'dotfiles/.config/calcurse/hooks')
-rwxr-xr-x | dotfiles/.config/calcurse/hooks/post-save | 31 | ||||
-rwxr-xr-x | dotfiles/.config/calcurse/hooks/pre-load | 25 |
2 files changed, 56 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..28c0ed8 --- /dev/null +++ b/dotfiles/.config/calcurse/hooks/post-save @@ -0,0 +1,31 @@ +#!/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 + +# Do not do anything when synchronizing with a CalDAV server. +[ -f "$data_dir/caldav/lock" ] && exit + +# Run the CalDAV synchronization script. +cd "$data_dir" || exit +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 + ) >>caldav/log 2>&1 +fi diff --git a/dotfiles/.config/calcurse/hooks/pre-load b/dotfiles/.config/calcurse/hooks/pre-load new file mode 100755 index 0000000..577736f --- /dev/null +++ b/dotfiles/.config/calcurse/hooks/pre-load @@ -0,0 +1,25 @@ +#!/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 +# $XDG_CONFIG_HOME/calcurse/hooks/ (~/.config/calcurse/hooks/) or +# ~/.calcurse/hooks/ if using ~/.calcurse. + +[ -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')" + echo "$date Running calcurse-caldav from the pre-load hook..." + calcurse-caldav + echo + ) >>caldav/log 2>&1 +fi |