diff options
Diffstat (limited to '.local/share')
-rwxr-xr-x | .local/share/bin/mode | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/.local/share/bin/mode b/.local/share/bin/mode index 654f0fe..fdec7e6 100755 --- a/.local/share/bin/mode +++ b/.local/share/bin/mode @@ -6,6 +6,28 @@ get_color() { xrdb -query | grep $1 | head -n1 | cut -f2 } +hex_to_rgb_array() { + printf "%d\n%d\n%d\n" "0x${1:1:2}" "0x${1:3:2}" "0x${1:5:2}" | jq -jc --slurp '.' +} + +get_color_rgb_array() { + hex_to_rgb_array "`get_color $1`" +} + +mix_rgb() { + R1="`printf "%d" "0x${1:1:2}"`" + G1="`printf "%d" "0x${1:3:2}"`" + B1="`printf "%d" "0x${1:5:2}"`" + R2="`printf "%d" "0x${2:1:2}"`" + G2="`printf "%d" "0x${2:3:2}"`" + B2="`printf "%d" "0x${2:5:2}"`" + + printf "#" + dc -e"$R1 $3 * $R2 1 $3 - * + 1 / p" | xargs printf "%02x" + dc -e"$G1 $3 * $G2 1 $3 - * + 1 / p" | xargs printf "%02x" + dc -e"$B1 $3 * $B2 1 $3 - * + 1 / p" | xargs printf "%02x" +} + switch_xrdb() { cat ~/.config/X11/base ~/.config/X11/$1 | xrdb } @@ -132,8 +154,41 @@ EOF switch_chrome() { cd ~/.cache/wal/chromium rm -f Cached Theme.pak bg.png manifest.json - ln -sf "bg-$1.png" bg.png - ln -sf "manifest-$1.json" manifest.json + convert -size 100x100 "xc:`get_color background`" bg.png + BG_ALT=$(mix_rgb $(get_color color8) $(get_color color0) '0.2') + jq -nc \ + --argjson bg "`get_color_rgb_array color0`" \ + --argjson bg_alt "`hex_to_rgb_array $BG_ALT`" \ + --argjson fg "`get_color_rgb_array color7`" \ + --argjson fg_alt "`get_color_rgb_array color8`" \ + '{ + "description": "colorscheme generated by mode", + "manifest_version": 2, + "name": "mode theme", + "theme": { + "images": { "theme_frame": "bg.png" }, + "colors": { + "frame": $bg, + "button_background": $fg, + "ntp_background": $bg, + "ntp_text": $bg, + "toolbar": $bg_alt, + "tab_background_text": $fg_alt, + "tab_background_text_inactive": $fg_alt, + "tab_background_text_incognito": $fg_alt, + "tab_background_text_incognito_inactive": $fg_alt, + "bookmark_text": $fg, + "tab_text": $fg + }, + "tints": { + "buttons": [ -1, -1, -1 ], + "frame_inactive": [ -1, -1, -1 ], + "frame_incognito": [ -1, -1, -1 ], + "frame_incognito_inactive": [ -1, -1, -1 ] + } + }, + "version": "2" + }' > manifest.json } reload_terms() { |