diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-03-13 21:58:42 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-03-13 22:00:25 +0100 |
commit | d6180ac911b1c6bf3e08115a20421802d5e3685d (patch) | |
tree | a9c9617b6296a08fc1a2cb5b83ce277c2b03f208 /.config/vdirsyncer | |
parent | 89149ca87b03fcbfca7a8faa8947c51636f85129 (diff) |
WIP add khard configuration
Diffstat (limited to '.config/vdirsyncer')
-rw-r--r-- | .config/vdirsyncer/config.sh.example | 2 | ||||
-rwxr-xr-x | .config/vdirsyncer/config_gen | 54 |
2 files changed, 35 insertions, 21 deletions
diff --git a/.config/vdirsyncer/config.sh.example b/.config/vdirsyncer/config.sh.example index 82d7878..0c7d81a 100644 --- a/.config/vdirsyncer/config.sh.example +++ b/.config/vdirsyncer/config.sh.example @@ -13,6 +13,8 @@ # NOTE: color and display name are automatically downloaded from the server, # and can not be set manually caldav 'https://dav.example.com' 'username' "$(pass www/dav.example.com/username)" +# `caldav` only syncs calendar items. you can replace `caldav` with `carddav` +# to only sync address books, or replace it with `dav` to sync both ### Web calendar example # NOTE: url should start with http(s)://, not webcal:// diff --git a/.config/vdirsyncer/config_gen b/.config/vdirsyncer/config_gen index 2e536d5..bf5d570 100755 --- a/.config/vdirsyncer/config_gen +++ b/.config/vdirsyncer/config_gen @@ -5,8 +5,6 @@ CONFIG_FILE="$(dirname "$0")/config.sh" exit 1 } -CFG_MODE="$1" - VDIRSYNCER_PREFIX="$XDG_DATA_HOME/vdirsyncer" VDIRSYNCER_STATUS_PATH="$VDIRSYNCER_PREFIX/status" @@ -14,7 +12,7 @@ VDIRSYNCER_STATUS_PATH="$VDIRSYNCER_PREFIX/status" safeify() { echo "$1" | sha1sum | cut -c1-40 ; } # safeify() { echo "$1" | tr -c '0-9A-Za-z' '_' | sed 's/_\+/_/g' ; } -[ "$CFG_MODE" != "lib" ] && cat << EOF +[ -z "$EXPORT_LIB" ] && cat << EOF # THIS FILE IS AUTO-GENERATED AND SHOULD NOT BE SAVED TO DISK!!! Use with # vdirsyncer by piping the output of this script to a named pipe. @@ -23,7 +21,8 @@ status_path = "$VDIRSYNCER_STATUS_PATH" EOF -_cfg_caldav() { +[ -n "$EXPORT_LIB" ] && _cfg_dav() { true ; } +[ -z "$EXPORT_LIB" ] && _cfg_dav() { cat << EOF [pair $ID] a = "${ID}_local" @@ -34,11 +33,11 @@ metadata = ["displayname", "color"] [storage ${ID}_local] type = "filesystem" path = "$VDIRSYNCER_PREFIX/$ID/" -fileext = ".ics" +fileext = "$FILEEXT" [storage ${ID}_remote] -type = "caldav" -url = "${BASE_URL}" +type = "$DAV_TYPE" +url = "$BASE_URL" EOF [ -n "$USERNAME" ] && echo "username = \"$USERNAME\"" [ -n "$PASSWORD" ] && echo "password = \"$PASSWORD\"" @@ -46,18 +45,8 @@ EOF echo # trailing blank line } -caldav() { - BASE_URL="$1" - USERNAME="$2" # optional - PASSWORD="$3" # optional - - NAME="$(echo "$BASE_URL" | sed -e 's#^https\?://##' -e 's#/.*##')" - ID="$(safeify "$NAME")" - - _cfg_caldav -} - -_cfg_ical() { +[ -n "$EXPORT_LIB" ] && _cfg_ical() { true ; } +[ -z "$EXPORT_LIB" ] && _cfg_ical() { cat << EOF [pair $ID] a = "${ID}_remote" @@ -91,9 +80,32 @@ ical() { _cfg_ical } +caldav() { DAV_TYPE="caldav" dav "$@" ; } +carddav() { DAV_TYPE="carddav" dav "$@" ; } +dav() { + BASE_URL="$1" + USERNAME="$2" # optional + PASSWORD="$3" # optional + + ID="$(safeify "$(echo "$BASE_URL$DAV_TYPE" | sed -e 's#^https\?://##' -e 's#/.*##')")" + + [ "$DAV_TYPE" = "caldav" ] && FILEEXT=".ics" + [ "$DAV_TYPE" = "carddav" ] && FILEEXT=".vcf" + + # only generate specific DAV config if explicitly defined + if [ -n "$DAV_TYPE" ] ; then + _cfg_dav + return + fi + + # else generate both + caldav "$@" + carddav "$@" +} + # load "actual" config file -[ "$CFG_MODE" != "lib" ] && . "$CONFIG_FILE" +[ -z "$EXPORT_LIB" ] && . "$CONFIG_FILE" # make inspecting output easier -[ "$CFG_MODE" != "lib" ] && printf '# %s:%s=%s\n' vim ft dosini +[ -z "$EXPORT_LIB" ] && printf '# %s:%s=%s\n' vim ft dosini |