Improve light-dark toggle speed and Vim

This commit is contained in:
Tibo De Peuter 2023-11-06 10:45:26 +01:00
parent c096c1b753
commit a83bbaa0cc
2 changed files with 19 additions and 3 deletions

View file

@ -20,6 +20,10 @@ declare -A gsettings_alt
gsettings_alt[${THEME_LIGHT}]='default' gsettings_alt[${THEME_LIGHT}]='default'
gsettings_alt[${THEME_DARK}]='prefer-dark' gsettings_alt[${THEME_DARK}]='prefer-dark'
declare -A wallpaper
wallpaper[${THEME_LIGHT}]="bg"
wallpaper[${THEME_DARK}]="bg-dark"
############# #############
### Logic ### ### Logic ###
############# #############
@ -63,19 +67,24 @@ echo "${theme:=${THEME_DEFAULT}}" > "${STATE_FILE}"
# GNOME # GNOME
if [ "$(command -v gsettings)" ]; then if [ "$(command -v gsettings)" ]; then
gsettings set org.gnome.desktop.interface color-scheme "${gsettings_alt[${theme}]}" gsettings set org.gnome.desktop.interface color-scheme "${gsettings_alt[${theme}]}" &
fi fi
# Kitty # Kitty
if [ "$(command -v kitty)" ]; then if [ "$(command -v kitty)" ]; then
kitten themes --config-file-name theme.conf "${theme}" kitten themes --reload-in all --config-file-name theme.conf "${theme}" &
fi
# Sway
if [ "$(command -v swaybg)" ]; then
pkill swaybg && swaybg -i ~/Nextcloud/Afbeeldingen/wallpapers/${wallpaper[${theme}]} && swaymsg reload &
fi fi
# Vifm # Vifm
if [ "$(command -v vifm)" ]; then if [ "$(command -v vifm)" ]; then
echo "colorscheme ${theme} Default-256 Default" > ~/.config/vifm/theme.conf echo "colorscheme ${theme} Default-256 Default" > ~/.config/vifm/theme.conf
# Update all running instances # Update all running instances
vifm --remote -c "colorscheme ${theme}" vifm --remote -c "colorscheme ${theme}" &
fi fi
# Vim # Vim
@ -83,5 +92,9 @@ fi
# Toggle an existing window using `:colorscheme ${theme}` # Toggle an existing window using `:colorscheme ${theme}`
if [ "$(command -v vim)" ]; then if [ "$(command -v vim)" ]; then
echo "colorscheme ${theme}" > ~/.vim/theme.conf echo "colorscheme ${theme}" > ~/.vim/theme.conf
# Update all running instances
for server in $(vim --serverlist); do
vim --servername "${server}" --remote-send "<C-\><C-N>:colorscheme ${theme}<CR>"
done
fi fi

View file

@ -51,6 +51,9 @@ if $TERM == 'xterm-kitty'
set term=xterm-256color set term=xterm-256color
endif endif
" Automatically start vim in a server - enable colorscheme switching
call remote_startserver("VIM")
" AUTO ------------------------------------------------------------------ {{{ " AUTO ------------------------------------------------------------------ {{{
if has("autocmd") if has("autocmd")