From d2f181ab0dd4a399c6923c8b32733eb7dc8ce051 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Tue, 21 Dec 2021 15:45:37 +0100 Subject: [PATCH] Add kitty socket to kitty scripts --- bin/padding | 5 +++-- bin/updatecolors | 9 +++------ vim/plugin/colors.vim | 14 +++++++------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/bin/padding b/bin/padding index 70de483..79790f1 100755 --- a/bin/padding +++ b/bin/padding @@ -17,7 +17,8 @@ then r="$4" else r="$l" fi -if [ "$TERM" = "xterm-kitty" ] +if ! [ "$TERM" = "xterm-kitty" ] then - kitty @ set-spacing padding-top=$t padding-left=$l padding-bottom=$b padding-right=$r + /bin/echo -e '\033[33mWarning: not running inside Kitty!\033[0m' fi +kitty @ --to $KITTY_LISTEN_ON set-spacing padding-top=$t padding-left=$l padding-bottom=$b padding-right=$r diff --git a/bin/updatecolors b/bin/updatecolors index 34b8cb8..e528b54 100755 --- a/bin/updatecolors +++ b/bin/updatecolors @@ -10,6 +10,7 @@ then gsettings set org.cinnamon.theme name "$theme" gsettings set org.cinnamon.desktop.interface icon-theme "$theme" gsettings set org.cinnamon.desktop.interface gtk-theme "$theme" + gsettings set org.gnome.desktop.background picture-uri "file://$HOME/wallpaper/dark.png" theme=dark else sed -i -e 's/kitty_dark.conf/kitty_light.conf/' $HOME/.config/kitty/kitty.conf @@ -20,18 +21,14 @@ else gsettings set org.cinnamon.theme name "$theme" gsettings set org.cinnamon.desktop.interface icon-theme "$theme" gsettings set org.cinnamon.desktop.interface gtk-theme "$theme" + gsettings set org.gnome.desktop.background picture-uri "file://$HOME/wallpaper/light.png" theme=light fi for socket in $(find /tmp/ -maxdepth 1 -name "kitty-$USER-*") do if which kitty > /dev/null; then - cat $HOME/darkrc/kitty_$theme.conf |\ - grep '^[[:alpha:]]' |\ - sed -s 's/ \+/=/' |\ - sed -s 's/^.*$/set-colors --all \0/' |\ - sort |\ - kitty @ --to unix:$socket >/dev/null + kitty @ --to unix:$socket set-colors --configured $HOME/darkrc/kitty_$theme.conf >/dev/null fi done diff --git a/vim/plugin/colors.vim b/vim/plugin/colors.vim index 8791e70..7d2eec9 100644 --- a/vim/plugin/colors.vim +++ b/vim/plugin/colors.vim @@ -2,15 +2,17 @@ let g:only_generic_hl=1 function! s:kitty_bg_color() - if $TERM=="xterm-kitty" + if $TERM=="xterm-kitty" || $KITTY_LISTEN_ON != "" let l:num_color=synIDattr(hlID("normal"), "bg") if l:num_color!="" - let l:color=system("kitty @ get-colors | grep 'color".l:num_color."'") + let l:color=system("kitty @ --to $KITTY_LISTEN_ON get-colors | grep 'color".l:num_color."'") let l:color=l:color[match(l:color, "#"):] - echom system('kitty @ set-colors background="'.l:color.'"') + call system('kitty @ --to $KITTY_LISTEN_ON set-colors background="'.l:color.'"') + call system("cat ".$HOME."/darkrc/kitty_".&bg.".conf | grep cursor | sed -e 's/ /=/' | xargs -L 1 kitty @ --to $KITTY_LISTEN_ON set-colors") end end endfun + augroup kitty au ColorScheme * call kitty_bg_color() augroup END @@ -21,12 +23,10 @@ function! s:kitty_bg_color_reset() else let l:file = $HOME."/darkrc/kitty_light.conf" end - echom system("cat ".l:file." | grep background | sed -e 's/ /=/' | xargs kitty @ set-colors") + call system("kitty @ --to ".$KITTY_LISTEN_ON." set-colors ".l:file) endfun -command Test call kitty_bg_color_reset() - -if $TERM=="xterm-kitty" +if $TERM=="xterm-kitty" || $KITTY_LISTEN_ON != "" augroup kitty au VimLeavePre * call kitty_bg_color_reset() augroup END