aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x.config/khal/config_gen18
-rw-r--r--.config/khard/base45
l---------.config/khard/config.sh1
-rwxr-xr-x.config/khard/config_gen25
-rw-r--r--.config/polybar/config.ini##template12
-rw-r--r--.config/vdirsyncer/config.sh.example2
-rwxr-xr-x.config/vdirsyncer/config_gen54
-rwxr-xr-x.local/share/bin/khard12
8 files changed, 137 insertions, 32 deletions
diff --git a/.config/khal/config_gen b/.config/khal/config_gen
index 683cd17..3f982c5 100755
--- a/.config/khal/config_gen
+++ b/.config/khal/config_gen
@@ -1,5 +1,5 @@
#!/bin/sh
-. "$XDG_CONFIG_HOME/vdirsyncer/config_gen" lib
+EXPORT_LIB=y . "$XDG_CONFIG_HOME/vdirsyncer/config_gen"
cat << EOF
[calendars]
@@ -12,20 +12,20 @@ _sync() {
vdirsyncer metasync 1> /dev/null 2> /dev/null
}
-_hexfmt() { sed 's/#\?\(..\)\(..\)\(..\)/0x\1 0x\2 0x\3/g' ; }
-TERMINAL_COLORS="$(for n in $(seq 0 15) ; do xrdb -get "color$n" ; done | _hexfmt)"
+color_fmt() { pastel format hsl | tr -d 'hsl(,%)' | sed 's/\.[^ ]\+//g' ; }
+TERMINAL_COLORS="$(for n in $(seq 0 15) ; do xrdb -get "color$n" ; done | color_fmt)"
_color_quantize() {
- INPUT="$(echo $1 | grep -o '#[0-9a-fA-F]\{6\}' | _hexfmt)"
+ INPUT="$(echo $1 | grep -o '#[0-9a-fA-F]\{6\}' | color_fmt)"
COLOR="$(printf '%s\n%s' "$INPUT" "$TERMINAL_COLORS" | awk --non-decimal-data '
# abs() is not built-in???
function abs(v) { return v < 0 ? -v : v }
BEGIN {
closest = 0; # closest ANSI color index
- # max diff can at most be 3 * 255 (see diff calculation)
- max_diff = 0xff * 3;
# offset line number once for input color, and another time to make color
# numbers start from 0 (line numbers start from 1 by default)
NR -= 2;
+ # keep track of the first color
+ first = 1;
}
{
# first line of input contains input colors
@@ -38,7 +38,8 @@ _color_quantize() {
if (NR == 0) next; # do not pick background color
# sloppy check to nearest RGB color
diff = abs(input_r - $1) + abs(input_g - $2) + abs(input_b - $3);
- if (diff < max_diff) {
+ if (diff < max_diff || first) {
+ first = 0;
max_diff = diff;
closest = NR;
}
@@ -65,7 +66,8 @@ _color_quantize() {
esac
}
-_cfg_caldav() {
+_cfg_dav() {
+ [ "$DAV_TYPE" != "caldav" ] && return
jq --raw-output '.collections[][0]' "$VDIRSYNCER_STATUS_PATH/$ID.collections" | while read -r collection ; do
collection_path="$XDG_DATA_HOME/vdirsyncer/$ID/$collection"
color_path="$collection_path/color"
diff --git a/.config/khard/base b/.config/khard/base
new file mode 100644
index 0000000..9be1796
--- /dev/null
+++ b/.config/khard/base
@@ -0,0 +1,45 @@
+[general]
+debug = no
+default_action = list
+editor = vim, -i, NONE
+merge_editor = vimdiff
+
+[contact table]
+# display names by first or last name: first_name / last_name / formatted_name
+display = first_name
+# group by address book: yes / no
+group_by_addressbook = no
+# reverse table ordering: yes / no
+reverse = no
+# append nicknames to name column: yes / no
+show_nicknames = no
+# show uid table column: yes / no
+show_uids = yes
+# show kind table column: yes / no
+show_kinds = no
+# sort by first or last name: first_name / last_name / formatted_name
+sort = last_name
+# localize dates: yes / no
+localize_dates = yes
+# set a comma separated list of preferred phone number types in descending priority
+# or nothing for non-filtered alphabetical order
+preferred_phone_number_type = pref, cell, home
+# set a comma separated list of preferred email address types in descending priority
+# or nothing for non-filtered alphabetical order
+preferred_email_address_type = pref, work, home
+
+[vcard]
+# extend contacts with your own private objects
+# these objects are stored with a leading "X-" before the object name in the vcard files
+# every object label may only contain letters, digits and the - character
+# example:
+# private_objects = Jabber, Skype, Twitter
+# default: , (the empty list)
+private_objects = Jabber, Skype, Twitter
+# preferred vcard version: 3.0 / 4.0
+preferred_version = 3.0
+# Look into source vcf files to speed up search queries: yes / no
+search_in_source_files = no
+# skip unparsable vcard files: yes / no
+skip_unparsable = no
+
diff --git a/.config/khard/config.sh b/.config/khard/config.sh
new file mode 120000
index 0000000..ecf2581
--- /dev/null
+++ b/.config/khard/config.sh
@@ -0,0 +1 @@
+../vdirsyncer/config.sh \ No newline at end of file
diff --git a/.config/khard/config_gen b/.config/khard/config_gen
new file mode 100755
index 0000000..75f59b1
--- /dev/null
+++ b/.config/khard/config_gen
@@ -0,0 +1,25 @@
+#!/bin/sh
+EXPORT_LIB=y . "$XDG_CONFIG_HOME/vdirsyncer/config_gen"
+
+cat << EOF
+[addressbooks]
+
+EOF
+
+_cfg_dav() {
+ [ "$DAV_TYPE" != "carddav" ] && return
+ jq --raw-output '.collections[][0]' "$VDIRSYNCER_STATUS_PATH/$ID.collections" | while read -r collection ; do
+ collection_path="$XDG_DATA_HOME/vdirsyncer/$ID/$collection"
+ displayname_path="$collection_path/displayname"
+ NAME="$(cat "$displayname_path")"
+ cat << EOF
+[[$NAME]]
+path = "$collection_path"
+EOF
+ echo
+ done
+}
+
+. "$CONFIG_FILE"
+
+printf '# %s:%s=%s\n' vim ft dosini
diff --git a/.config/polybar/config.ini##template b/.config/polybar/config.ini##template
index b5d5d87..a63b924 100644
--- a/.config/polybar/config.ini##template
+++ b/.config/polybar/config.ini##template
@@ -49,7 +49,7 @@ modules-right = wireless keyboard volume whoami
{% else %}
modules-left = time date cal
modules-center = mpd
-modules-right = wacomtouch keyboard volume whoami
+modules-right = dppt wacomtouch keyboard volume whoami
{% endif %}
separator =
@@ -119,15 +119,21 @@ exec = echo "%{T2}$(id -u -n)%{T-}@%{T2}$(uname -n)%{T-}"
interval = 9999999
label-font = 2
+[module/dppt]
+type = custom/script
+exec = dppt polybar
+tail = true
+click-left = dppt toggle
+click-middle = dppt reset
+
[module/keyboard]
type = custom/script
exec = ~/.local/share/bin/kbindicator
tail = true
-label-font = 1
[module/cal]
type = custom/script
-exec = khal list now tomorrow --notstarted --day-format '' --format '({start-time}) {calendar-color}{title}{reset}'
+exec = khal --color list now tomorrow --notstarted --day-format '' --format '({start-time}) {calendar-color}{title}{reset}' | ansi2polybar
interval = 60
# TODO: create script for converting ASCII escape codes to polybar/lemonbar formatting tags
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
diff --git a/.local/share/bin/khard b/.local/share/bin/khard
new file mode 100755
index 0000000..cb02889
--- /dev/null
+++ b/.local/share/bin/khard
@@ -0,0 +1,12 @@
+#!/bin/sh
+CFG="$XDG_CONFIG_HOME/khard/khard.conf"
+if [ "$CFG" -ot "$XDG_CONFIG_HOME/khard/config.sh" ] ; then
+ cat - "$XDG_CONFIG_HOME/khard/base" << "EOF" > "$CFG"
+# THIS FILE IS AUTO-GENERATED, EDIT config_gen OR base INSTEAD!!!
+
+EOF
+ "$XDG_CONFIG_HOME/khard/config_gen" >> "$CFG"
+fi
+
+exec /usr/bin/khard "$@"
+