# HG changeset patch # User Sean E. Russell # Date 1634156250 18000 # Wed Oct 13 15:17:30 2021 -0500 # Node ID 4c41f0882a59ae83dff3ffcdd87745414e57134b # Parent 0000000000000000000000000000000000000000 Initial commit diff --git a/importicals b/importicals new file mode 100755 --- /dev/null +++ b/importicals @@ -0,0 +1,43 @@ +#!/bin/bash + +CALDIR=$HOME/.calendars +DDIR=$XDG_DATA_HOME/remind +mkdir -p "$DDIR" +FOUT="$DDIR/reminders" + +function help() { + printf "USAGE: $0 \n" + printf " import -- reload DB from %s\n" "$CALDIR" + printf " watch -- watch %s for new events and import them\n" "$CALDIR" + exit $1 +} + +case $1 in + import) + rm -f "$FOUT" + for dir in $(find $CALDIR -maxdepth 1 -mindepth 1 -type d -print) + do + LABEL=$(basename $dir) + printf "Processing %s\n " "$LABEL" + bar -c "ical2rem --label ${LABEL}" -o "$FOUT" $dir/*.ics + done + ;; + watch) + # fswatch regex inclusion is broken + fswatch ~/.calendars --event Created --event IsFile --recursive |\ + while read -r event; do + # because of the fswatch bug, we have to check this the hard way + echo "$event" | grep -qP '^.*\.ics$' + if [[ $? -eq 0 ]]; then + LABEL=$(basename "$event") + cat "$event" | ical2rem --label ${LABEL} >> "$FOUT" + fi + done + ;; + help) + help 0 + ;; + *) + help 1 + ;; +esac