diff options
Diffstat (limited to '.local/share/mode/plug.d')
-rw-r--r-- | .local/share/mode/plug.d/10_lib | 5 | ||||
-rw-r--r-- | .local/share/mode/plug.d/20_export_colors | 17 | ||||
-rw-r--r-- | .local/share/mode/plug.d/20_export_mode | 9 | ||||
-rw-r--r-- | .local/share/mode/plug.d/20_export_vim_theme | 6 | ||||
-rw-r--r-- | .local/share/mode/plug.d/50_accent | 16 |
5 files changed, 53 insertions, 0 deletions
diff --git a/.local/share/mode/plug.d/10_lib b/.local/share/mode/plug.d/10_lib new file mode 100644 index 0000000..61817bc --- /dev/null +++ b/.local/share/mode/plug.d/10_lib @@ -0,0 +1,5 @@ +#!/bin/sh +# utility library functions +hex_to_rgb_array() { pastel format rgb "$1" | cut -c4- | tr '()' '[]' ; } +mix_rgb() { pastel mix --colorspace=RGB --fraction="$3" "$1" "$2" | pastel format hex ; } + diff --git a/.local/share/mode/plug.d/20_export_colors b/.local/share/mode/plug.d/20_export_colors new file mode 100644 index 0000000..017446d --- /dev/null +++ b/.local/share/mode/plug.d/20_export_colors @@ -0,0 +1,17 @@ +#!/bin/sh +# colors must be #RRGGBB +check_color() { + ( + eval "color=\"\${$1}\"" + exit "$(echo "$color" | sed -n '/^#[0-9a-fA-F]\{6\}$/p' | wc -l)" + ) + if [ $? -ne 1 ] ; then + echo "error: color $1 is not properly formatted (#RRGGBB)" + stupid && exit 1 + fi + eval "export $1" +} +for color in $(seq 0 15 | sed 's/^/color/') bg fg ; do + check_color $color +done + diff --git a/.local/share/mode/plug.d/20_export_mode b/.local/share/mode/plug.d/20_export_mode new file mode 100644 index 0000000..78432b6 --- /dev/null +++ b/.local/share/mode/plug.d/20_export_mode @@ -0,0 +1,9 @@ +#!/bin/sh +# $mode = "light" | "dark" +if [ "$mode" != 'dark' ] && [ "$mode" != 'light' ] ; then + pastel format hsl-lightness "$bg" | awk '{ exit($1 > 0.5) }' + [ $? -eq 0 ] && mode=dark || mode=light + echo "warn: theme $theme did not define \$mode as \"light\" or \"dark\", guessed $mode" >&2 +fi +export mode + diff --git a/.local/share/mode/plug.d/20_export_vim_theme b/.local/share/mode/plug.d/20_export_vim_theme new file mode 100644 index 0000000..be76b8b --- /dev/null +++ b/.local/share/mode/plug.d/20_export_vim_theme @@ -0,0 +1,6 @@ +#!/bin/sh +# warn if the vim theme is not installed +if [ "$(find "$XDG_CONFIG_HOME/nvim" -name "$vim_theme_name.vim" | wc -l)" -eq 0 ] ; then + echo "warn: vim theme $vim_theme_name does not appear to be installed" >&2 +fi +export vim_theme_name diff --git a/.local/share/mode/plug.d/50_accent b/.local/share/mode/plug.d/50_accent new file mode 100644 index 0000000..6e0aa73 --- /dev/null +++ b/.local/share/mode/plug.d/50_accent @@ -0,0 +1,16 @@ +#!/bin/sh +# create accent color differently for dark/light mode + +# do not generate accent color if already explicitly defined by theme +[ -n "$accent" ] && return + +[ "$mode" == "light" ] && { + accent="$color15" + accent_text="$color0" +} +[ "$mode" == "dark" ] && { + accent="$(mix_rgb $bg $color0 0.5)" + accent_text="$fg" +} + +export accent accent_text |