diff options
Diffstat (limited to '.local/share/mode')
26 files changed, 519 insertions, 0 deletions
diff --git a/.local/share/mode/bin/mode b/.local/share/mode/bin/mode new file mode 100755 index 0000000..a4e6947 --- /dev/null +++ b/.local/share/mode/bin/mode @@ -0,0 +1,107 @@ +#!/bin/sh +progname="$(basename "$0")" +data="$(readlink -f "$(dirname "$(readlink -f "$0")")/..")" +export data + +stupid() { + echo "run \`$progname --help\` for options" >&2 +} +usage() { + cat << EOF +$progname -- switch system themes + +usage: + $progname [-chr] action|theme + +options: + -c, --no-cfggen disable updating of configuration files + -h, --help display this help text + -r, --no-reload disable reloading of applications after applying theme + +actions: + restore switch to last set theme ($XDG_CACHE_HOME/mode/state/theme) + reload do not update configuration files, only reload applications + help same as --help option + +themes: + $(ls "$data/themes" | tr '\n' ' ' | fold -sw 60) + +examples: + mode dark switch to dark mode and reload applications + mode restore --no-reload make sure all configuration files are up-to-date + mode reload only reload applications + +EOF +} + +. "$data/lib/functions.sh" + +switch() { + theme_path="$(readlink -f "$data/themes/$theme")" + theme="$(basename "$theme_path")" + echo "setting theme to $theme..." + + . "$theme_path" + + case "$mode" in + dark|light) break ;; + *) + echo "error: theme $theme does not define a valid \$mode" >&2 + stupid && exit 1 + ;; + esac + export mode + + # create accent color differently for dark/light mode + . "$data/lib/accent.sh" + + for switch_function in "$data"/switch.d/* ; do + ! [ -x "$switch_function" ] && continue + "$switch_function" & + done + + wait $(jobs -rp) +} + +reload() { + echo "reloading programs..." + + for reload_function in "$data"/reload.d/* ; do + ! [ -x "$reload_function" ] && continue + "$reload_function" & + done + + wait $(jobs -rp) +} + +run_cfggen=1 +run_reload=1 +theme="" + +for arg in "$@" ; do + case "$arg" in + --) break ;; + -h|--help|help) usage ; exit 0 ;; + restore) theme="$(cat "$XDG_CACHE_HOME/mode/state/theme")" ;; + reload) run_reload=1 run_cfggen=0 ;; + -r|--no-reload) run_reload=0 ;; + -c|--no-cfggen) run_cfggen=0 ;; + *) + if [ -e "$data/themes/$arg" ] ; then + theme="$arg" + continue + fi + echo "error: unknown argument or theme: $arg" >&2 + stupid && exit 1 + ;; + esac +done +if [ $run_cfggen -eq 1 ] && [ -z "$theme" ] ; then + echo "error: no theme selected" >&2 + stupid && exit 1 +fi +export theme + +[ $run_cfggen -eq 1 ] && switch +[ $run_reload -eq 1 ] && reload + diff --git a/.local/share/mode/lib/accent.sh b/.local/share/mode/lib/accent.sh new file mode 100644 index 0000000..45643eb --- /dev/null +++ b/.local/share/mode/lib/accent.sh @@ -0,0 +1,10 @@ +#!/bin/sh +[ "$mode" == "light" ] && { + export accent="$color15" + export accent_text="$color0" +} +[ "$mode" == "dark" ] && { + export accent="$(mix_rgb $bg $color0 0.5)" + export accent_text="$fg" +} + diff --git a/.local/share/mode/lib/functions.sh b/.local/share/mode/lib/functions.sh new file mode 100644 index 0000000..c7212e4 --- /dev/null +++ b/.local/share/mode/lib/functions.sh @@ -0,0 +1,4 @@ +#!/bin/sh +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/reload.d/brave b/.local/share/mode/reload.d/brave new file mode 100644 index 0000000..62fb08c --- /dev/null +++ b/.local/share/mode/reload.d/brave @@ -0,0 +1,11 @@ +#!/bin/sh + + +# - navigate to brave://settings +# - run `chrome.send("setBraveThemeType", [THEME_ENUM])` in js console +# values 1: dark +# 2: light +# - navigate to brave://extensions +# - run `chrome.send("setBraveThemeType", [THEME_ENUM])` in js console +# - run `chrome.developerPrivate.loadUnpacked()` (TODO: how to handle inputting file path non-interactively) +# TODO: how to use chromedriver from script (preferably without nodejs+npm or python3+pip dependencies?) diff --git a/.local/share/mode/reload.d/dunst b/.local/share/mode/reload.d/dunst new file mode 100755 index 0000000..3c09a31 --- /dev/null +++ b/.local/share/mode/reload.d/dunst @@ -0,0 +1,4 @@ +#!/bin/sh +killall dunst +fork dunst + diff --git a/.local/share/mode/reload.d/fcitx5 b/.local/share/mode/reload.d/fcitx5 new file mode 100755 index 0000000..cd27698 --- /dev/null +++ b/.local/share/mode/reload.d/fcitx5 @@ -0,0 +1,3 @@ +#!/bin/sh +fork fcitx5 -rd + diff --git a/.local/share/mode/reload.d/gtk b/.local/share/mode/reload.d/gtk new file mode 100755 index 0000000..178f895 --- /dev/null +++ b/.local/share/mode/reload.d/gtk @@ -0,0 +1,10 @@ +#!/bin/sh +# this is max jank but xfsettingsd does other things besides live gtk theme +# reloading, and i don't like having it running constantly because it fucks +# up fcitx5 and xbindkeys +( + fork xfsettingsd + sleep 1 + killall xfsettingsd +) + diff --git a/.local/share/mode/reload.d/nvim b/.local/share/mode/reload.d/nvim new file mode 100755 index 0000000..84ae847 --- /dev/null +++ b/.local/share/mode/reload.d/nvim @@ -0,0 +1,5 @@ +#!/bin/sh +nvr --serverlist | while read -r nvim_socket ; do + fork nvr --nostart --servername "$nvim_socket" -c 'source $XDG_CONFIG_HOME/nvim/mode.vim' +done + diff --git a/.local/share/mode/reload.d/polybar b/.local/share/mode/reload.d/polybar new file mode 100755 index 0000000..af39394 --- /dev/null +++ b/.local/share/mode/reload.d/polybar @@ -0,0 +1,3 @@ +#!/bin/sh +polybar-msg cmd restart > /dev/null + diff --git a/.local/share/mode/reload.d/term b/.local/share/mode/reload.d/term new file mode 100755 index 0000000..5f02463 --- /dev/null +++ b/.local/share/mode/reload.d/term @@ -0,0 +1,30 @@ +#!/bin/sh +escape_msgs="$(cat << EOF | tr -d '\n' +\033]11;$bg\007 +\033]10;$fg\007 +\033]12;$fg\007 +\033]14;$bg\007 +\033]13;$fg\007 +\033]17;$color8\007 +\033]708;$bg\007 +\033]4;0;$color0\007 +\033]4;1;$color1\007 +\033]4;2;$color2\007 +\033]4;3;$color3\007 +\033]4;4;$color4\007 +\033]4;5;$color5\007 +\033]4;6;$color6\007 +\033]4;7;$color7\007 +\033]4;8;$color8\007 +\033]4;9;$color9\007 +\033]4;10;$color10\007 +\033]4;11;$color11\007 +\033]4;12;$color12\007 +\033]4;13;$color13\007 +\033]4;14;$color14\007 +\033]4;15;$color15\007 +EOF +)" + +find /dev/pts -exec sh -c "printf \"$escape_msgs\" > {}" \; 2> /dev/null + diff --git a/.local/share/mode/reload.d/wall b/.local/share/mode/reload.d/wall new file mode 100755 index 0000000..f6c2e41 --- /dev/null +++ b/.local/share/mode/reload.d/wall @@ -0,0 +1,3 @@ +#!/bin/sh +rwall + diff --git a/.local/share/mode/switch.d/chromium b/.local/share/mode/switch.d/chromium new file mode 100755 index 0000000..5f4f342 --- /dev/null +++ b/.local/share/mode/switch.d/chromium @@ -0,0 +1,47 @@ +#!/bin/sh +. "$XDG_DATA_HOME/mode/lib/functions.sh" + +PREFIX="$XDG_CACHE_HOME/mode/chromium" + +mkdir -p "$PREFIX" +rm -f "$PREFIX/Cached Theme.pak" + +convert -size 100x100 "xc:$bg" "$PREFIX/bg.png" +bg_alt=$(mix_rgb $color7 $bg 0.20) +fg_alt=$(mix_rgb $color15 $fg 0.60) +bg="$(hex_to_rgb_array "$bg")" +fg="$(hex_to_rgb_array "$fg")" +bg_alt="$(hex_to_rgb_array "$bg_alt")" +fg_alt="$(hex_to_rgb_array "$fg_alt")" +cat << EOF > "$PREFIX/manifest.json" +{ + "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, + "toolbar_button_icon": $fg, + "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" +} +EOF + diff --git a/.local/share/mode/switch.d/discord b/.local/share/mode/switch.d/discord new file mode 100755 index 0000000..2a08662 --- /dev/null +++ b/.local/share/mode/switch.d/discord @@ -0,0 +1,33 @@ +#!/bin/sh +. "$data/lib/functions.sh" + +cat << EOF > "$XDG_CONFIG_HOME/BetterDiscord/themes/mode.theme.css" +/** + * @name mode + * @author mode + * @version 0 +*/ + +/* AUTOMATICALLY GENERATED, DO NOT EDIT */ + +.theme-dark, .theme-light { + --background-primary: $bg; + --background-secondary: $bg; + --background-secondary-alt: $bg; + --text-primary: $fg; + --text-secondary: $color15; + --accent: $color4; + --accent-alt: $color12; + --error: $color1; + --error-alt: $color9; +} + +.theme-dark { + --background-tertiary: $(mix_rgb $bg '#000000' 0.7); +} + +.theme-light { + --background-tertiary: $bg; +} +EOF + diff --git a/.local/share/mode/switch.d/dunst b/.local/share/mode/switch.d/dunst new file mode 100755 index 0000000..2a5a60e --- /dev/null +++ b/.local/share/mode/switch.d/dunst @@ -0,0 +1,21 @@ +#!/bin/sh +cat "$XDG_CONFIG_HOME/dunst/base" - << EOF > "$XDG_CONFIG_HOME/dunst/dunstrc" +frame_color = "$color0" + +[urgency_low] +background = "$bg" +foreground = "$fg" +timeout = 10 + +[urgency_normal] +background = "$bg" +foreground = "$fg" +timeout = 10 + +[urgency_critical] +background = "$color1" +foreground = "$bg" +frame_color = "$color1" +timeout = 0 +EOF + diff --git a/.local/share/mode/switch.d/fcitx5 b/.local/share/mode/switch.d/fcitx5 new file mode 100755 index 0000000..ee99f13 --- /dev/null +++ b/.local/share/mode/switch.d/fcitx5 @@ -0,0 +1,28 @@ +#!/bin/sh +cat "$XDG_DATA_HOME/fcitx5/themes/loek/base.conf" - << EOF > "$XDG_DATA_HOME/fcitx5/themes/loek/theme.conf" +[InputPanel] +NormalColor=$fg +HighlightCandidateColor=$accent_text +HighlightColor=$color13 +HighlightBackgroundColor=$bg + +[InputPanel/Background] +Color=$bg +BorderColor=$accent + +[InputPanel/Highlight] +Color=$accent + +[Menu/Background] +Color=$bg + +[Menu] +NormalColor=$fg + +[Menu/Highlight] +Color=$accent + +[Menu/Separator] +Color=$color7 +EOF + diff --git a/.local/share/mode/switch.d/gtk b/.local/share/mode/switch.d/gtk new file mode 100755 index 0000000..63a2f83 --- /dev/null +++ b/.local/share/mode/switch.d/gtk @@ -0,0 +1,14 @@ +#!/bin/sh +GTK_3_SETTINGS_INI="$XDG_CONFIG_HOME/gtk-3.0/settings.ini" +GTK_4_SETTINGS_ENV="$XDG_CONFIG_HOME/gtk-4.0/env" +if [ "$mode" = "light" ]; then + sed 's/^\(export\s\+GTK_THEME=.\+\)-Dark\(.*\)$/\1-Light\2/g' -i "$GTK_4_SETTINGS_ENV" + sed "s/-Dark/-Light/" -i "$GTK_3_SETTINGS_INI" + sed "s/gtk-application-prefer-dark-theme.*/gtk-application-prefer-dark-theme=false/" -i "$GTK_3_SETTINGS_INI" +else + sed 's/^\(export\s\+GTK_THEME=.\+\)-Light\(.*\)$/\1-Dark\2/g' -i "$GTK_4_SETTINGS_ENV" + sed "s/-Light/-Dark/" -i "$GTK_3_SETTINGS_INI" + sed "s/gtk-application-prefer-dark-theme.*/gtk-application-prefer-dark-theme=true/" -i "$GTK_3_SETTINGS_INI" +fi +grep gtk-theme-name "$GTK_3_SETTINGS_INI" | cut -f2 -d= | xargs xfconf-query -c xsettings -p /Net/ThemeName -s + diff --git a/.local/share/mode/switch.d/mode b/.local/share/mode/switch.d/mode new file mode 100755 index 0000000..17b981c --- /dev/null +++ b/.local/share/mode/switch.d/mode @@ -0,0 +1,8 @@ +#!/bin/sh +PREFIX="$XDG_CACHE_HOME/mode/state" +rm -rf "$PREFIX"/* +mkdir -p "$PREFIX" + +echo "$mode" > "$PREFIX/mode" +echo "$theme" > "$PREFIX/theme" + diff --git a/.local/share/mode/switch.d/polybar b/.local/share/mode/switch.d/polybar new file mode 100755 index 0000000..b7e752a --- /dev/null +++ b/.local/share/mode/switch.d/polybar @@ -0,0 +1,13 @@ +#!/bin/sh +cat << EOF > "$XDG_CONFIG_HOME/polybar/colors.ini" +[color] +bg = \${xrdb:background:$bg} +fg = \${xrdb:foreground:$fg} +fg-alt = \${xrdb:background:$bg} +fg-half = \${xrdb:color8:$color8} + +alpha = #00000000 + +; vim:ft=dosini +EOF + diff --git a/.local/share/mode/switch.d/rofi b/.local/share/mode/switch.d/rofi new file mode 100755 index 0000000..19b9008 --- /dev/null +++ b/.local/share/mode/switch.d/rofi @@ -0,0 +1,8 @@ +#!/bin/sh +cat << EOF > "$XDG_CONFIG_HOME/rofi/colors" +export background="$bg" +export foreground="$fg" +export accent="$accent" +export accent_text="$accent_text" +EOF + diff --git a/.local/share/mode/switch.d/vim b/.local/share/mode/switch.d/vim new file mode 100755 index 0000000..6c83f9f --- /dev/null +++ b/.local/share/mode/switch.d/vim @@ -0,0 +1,58 @@ +#!/bin/sh +PREFIX="$XDG_CONFIG_HOME/nvim/mode" +mkdir -p "$PREFIX" + +# lightline +cat << EOF > "$PREFIX/lightline.vim" +let s:bg = [ '$bg', 'NONE' ] +let s:fg = [ '$fg', 'NONE' ] +let s:mode = [ '$color0', 'NONE' ] +let s:faint = [ '$color8', 'NONE' ] +let s:none = [ 'NONE', 'NONE' ] +let s:test = [ '#ff00ff', 'NONE' ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:fg, s:mode ], [ s:faint, s:bg ] ] +let s:p.normal.right = [ [ s:faint, s:bg ] ] +let s:p.normal.middle = [ [ s:none, s:none ] ] +let s:p.normal.error = [ [ s:test, s:test ] ] +let s:p.normal.warning = [ [ s:test, s:test ] ] +let s:p.inactive.left = copy(s:p.normal.left) +let s:p.inactive.right = copy(s:p.normal.right) +let s:p.inactive.middle = copy(s:p.normal.middle) +let s:p.insert.left = copy(s:p.normal.left) +let s:p.replace.left = copy(s:p.insert.left) +let s:p.visual.left = copy(s:p.insert.left) +let s:p.tabline.left = copy(s:p.normal.right) +let s:p.tabline.tabsel = [ [ s:fg, s:mode ] ] +let s:p.tabline.middle = copy(s:p.normal.right) +let s:p.tabline.right = copy(s:p.normal.right) + +let g:lightline#colorscheme#auto#palette = lightline#colorscheme#flatten(s:p) +EOF + +# terminal colors +cat << EOF > "$PREFIX/termcolors.vim" +let g:terminal_color_0 = '$color0' +let g:terminal_color_1 = '$color1' +let g:terminal_color_2 = '$color2' +let g:terminal_color_3 = '$color3' +let g:terminal_color_4 = '$color4' +let g:terminal_color_5 = '$color5' +let g:terminal_color_6 = '$color6' +let g:terminal_color_7 = '$color7' +let g:terminal_color_8 = '$color8' +let g:terminal_color_9 = '$color9' +let g:terminal_color_10 = '$color10' +let g:terminal_color_11 = '$color11' +let g:terminal_color_12 = '$color12' +let g:terminal_color_13 = '$color13' +let g:terminal_color_14 = '$color14' +let g:terminal_color_15 = '$color15' +EOF + +# color scheme +cat << EOF > "$PREFIX/colorscheme.vim" +colorscheme $vim_theme_name +EOF + diff --git a/.local/share/mode/switch.d/xrdb b/.local/share/mode/switch.d/xrdb new file mode 100755 index 0000000..591a530 --- /dev/null +++ b/.local/share/mode/switch.d/xrdb @@ -0,0 +1,22 @@ +#!/bin/sh +cat << EOF | xrdb -override +*.color0: $color0 +*.color1: $color1 +*.color2: $color2 +*.color3: $color3 +*.color4: $color4 +*.color5: $color5 +*.color6: $color6 +*.color7: $color7 +*.color8: $color8 +*.color9: $color9 +*.color10: $color10 +*.color11: $color11 +*.color12: $color12 +*.color13: $color13 +*.color14: $color14 +*.color15: $color15 +*.foreground: $fg +*.background: $bg +EOF + diff --git a/.local/share/mode/switch.d/zathura b/.local/share/mode/switch.d/zathura new file mode 100755 index 0000000..0fde1d1 --- /dev/null +++ b/.local/share/mode/switch.d/zathura @@ -0,0 +1,27 @@ +#!/bin/sh +cat << EOF > "$XDG_CONFIG_HOME/zathura/colors" +set default-bg "$bg" +set statusbar-bg "$bg" +set inputbar-bg "$bg" +set completion-highlight-fg "$bg" +set completion-bg "$bg" +set notification-error-fg "$bg" +set notification-warning-fg "$bg" +set notification-fg "$bg" +set recolor-lightcolor "$bg" + +set default-fg "$fg" +set inputbar-fg "$fg" +set completion-fg "$fg" +set statusbar-fg "$fg" +set recolor-darkcolor "$fg" + +set notification-error-bg "$color9" +set notification-warning-bg "$color9" +set completion-highlight-bg "$color9" +set highlight-color "$color9" + +set highlight-active-color "$color13" +set notification-bg "$color13" +EOF + diff --git a/.local/share/mode/themes/dark b/.local/share/mode/themes/dark new file mode 120000 index 0000000..85ffa87 --- /dev/null +++ b/.local/share/mode/themes/dark @@ -0,0 +1 @@ +github-dark
\ No newline at end of file diff --git a/.local/share/mode/themes/github-dark b/.local/share/mode/themes/github-dark new file mode 100644 index 0000000..f2113a8 --- /dev/null +++ b/.local/share/mode/themes/github-dark @@ -0,0 +1,24 @@ +#!/bin/sh +export mode='dark' + +export color0='#484f58' +export color1='#ffa198' +export color2='#56d364' +export color3='#e3b341' +export color4='#79c0ff' +export color5='#d2a8ff' +export color6='#56d4dd' +export color7='#b1bac4' +export color8='#6e7681' +export color9='#ff7b72' +export color10='#3fb950' +export color11='#d29922' +export color12='#58a6ff' +export color13='#bc8cff' +export color14='#39c5cf' +export color15='#ffffff' + +export bg='#0d1117' +export fg='#e6edf3' + +export vim_theme_name='ghdark' diff --git a/.local/share/mode/themes/github-light b/.local/share/mode/themes/github-light new file mode 100644 index 0000000..d4a5c28 --- /dev/null +++ b/.local/share/mode/themes/github-light @@ -0,0 +1,24 @@ +#!/bin/sh +export mode='light' + +export color0='#d1d5da' +export color1='#cb2431' +export color2='#22863a' +export color3='#b08800' +export color4='#005cc5' +export color5='#5a32a3' +export color6='#3192aa' +export color7='#6a737d' +export color8='#959da5' +export color9='#d73a49' +export color10='#28a745' +export color11='#dbab09' +export color12='#0366d6' +export color13='#5a32a3' +export color14='#1b7c83' +export color15='#24292e' + +export bg='#ffffff' +export fg='#24292e' + +export vim_theme_name='github-light' diff --git a/.local/share/mode/themes/light b/.local/share/mode/themes/light new file mode 120000 index 0000000..7f41e3e --- /dev/null +++ b/.local/share/mode/themes/light @@ -0,0 +1 @@ +github-light
\ No newline at end of file |