From a7764f6878b4356897889c880e3abafaa111b653 Mon Sep 17 00:00:00 2001 From: coolneng Date: Mon, 12 Oct 2020 19:45:16 +0200 Subject: [PATCH] Add global dark/light theme switch with key bind --- kitty/.config/kitty/iceberg_dark.conf | 39 +++++++++++++++ kitty/.config/kitty/iceberg_light.conf | 40 +++++++++++++++ kitty/.config/kitty/kitty.conf | 59 +---------------------- neovim/.config/nvim/init.vim | 1 + scripts/.local/share/scripts/switch_theme | 27 +++++++++++ sway/.config/sway/config | 13 +++++ tmux/.tmux.conf | 2 +- tmux/.tmux/iceberg.tmux.conf | 19 -------- tmux/.tmux/iceberg_dark.tmux.conf | 10 ++++ tmux/.tmux/iceberg_light.tmux.conf | 10 ++++ 10 files changed, 142 insertions(+), 78 deletions(-) create mode 100644 kitty/.config/kitty/iceberg_dark.conf create mode 100644 kitty/.config/kitty/iceberg_light.conf create mode 100755 scripts/.local/share/scripts/switch_theme delete mode 100644 tmux/.tmux/iceberg.tmux.conf create mode 100644 tmux/.tmux/iceberg_dark.tmux.conf create mode 100644 tmux/.tmux/iceberg_light.tmux.conf diff --git a/kitty/.config/kitty/iceberg_dark.conf b/kitty/.config/kitty/iceberg_dark.conf new file mode 100644 index 0000000..b43277d --- /dev/null +++ b/kitty/.config/kitty/iceberg_dark.conf @@ -0,0 +1,39 @@ +background #161821 +foreground #c6c8d1 + +selection_background #1e2132 +selection_foreground #c6c8d1 + +cursor #d2d4de + +# black +color0 #161821 +color8 #6b7089 + +# red +color1 #e27878 +color9 #e98989 + +# green +color2 #b4be82 +color10 #c0ca8e + +# yellow/orange +color3 #e2a478 +color11 #e9b189 + +# blue +color4 #84a0c6 +color12 #91acd1 + +# magenta/purple +color5 #a093c7 +color13 #ada0d3 + +# cyan +color6 #89b8c2 +color14 #95c4ce + +# white +color7 #c6c8d1 +color15 #d2d4de \ No newline at end of file diff --git a/kitty/.config/kitty/iceberg_light.conf b/kitty/.config/kitty/iceberg_light.conf new file mode 100644 index 0000000..1114685 --- /dev/null +++ b/kitty/.config/kitty/iceberg_light.conf @@ -0,0 +1,40 @@ +background #e8e9ec +foreground #33374c + +selection_background #d2d4dd +selection_foreground #33374c + +cursor #33374c +cursor_text_color #e8e9ec + +# black +color0 #dcdfe7 +color8 #8389a3 + +# red +color1 #cc517a +color9 #cc3768 + +# green +color2 #668e3d +color10 #598030 + +# yellow/orange +color3 #c57339 +color11 #b6662d + +# blue +color4 #2d539e +color12 #22478e + +# magenta/purple +color5 #7759b4 +color13 #6845ad + +# cyan +color6 #3f83a6 +color14 #327698 + +# white +color7 #33374c +color15 #262a3f \ No newline at end of file diff --git a/kitty/.config/kitty/kitty.conf b/kitty/.config/kitty/kitty.conf index 259c420..ca73479 100644 --- a/kitty/.config/kitty/kitty.conf +++ b/kitty/.config/kitty/kitty.conf @@ -459,8 +459,7 @@ inactive_tab_font_style normal #: Color scheme {{{ -foreground #c6c8d1 -background #161821 +include iceberg_dark.conf #: The foreground and background colors @@ -490,62 +489,6 @@ dynamic_background_opacity no dim_opacity 0.75 -#: How much to dim text that has the DIM/FAINT attribute set. One -#: means no dimming and zero means fully dimmed (i.e. invisible). - -selection_foreground #000000 - -#: The foreground for text selected with the mouse. A value of none -#: means to leave the color unchanged. - -selection_background #fffacd - -#: The background for text selected with the mouse. - - -#: The 16 terminal colors. There are 8 basic colors, each color has a -#: dull and bright version. You can also set the remaining colors from -#: the 256 color table as color16 to color255. - -color0 #161821 -color8 #6b7089 - -#: black - -color1 #e27878 -color9 #e98989 - -#: red - -color2 #b4be82 -color10 #c0ca8e - -#: green - -color3 #e2a478 -color11 #e9b189 - -#: yellow - -color4 #84a0c6 -color12 #91acd1 - -#: blue - -color5 #a093c7 -color13 #ada0d3 - -#: magenta - -color6 #89b8c2 -color14 #95c4ce - -#: cyan - -color7 #c6c8d1 -color15 #d2d4de - -#: white #: }}} diff --git a/neovim/.config/nvim/init.vim b/neovim/.config/nvim/init.vim index 01d6045..d03d582 100644 --- a/neovim/.config/nvim/init.vim +++ b/neovim/.config/nvim/init.vim @@ -40,6 +40,7 @@ Plug 'cocopon/iceberg.vim' call plug#end() ""Colors colorscheme iceberg +set bg=dark set termguicolors ""Sets the colorscheme in tmux let &t_8f = "\[38;2;%lu;%lu;%lum" diff --git a/scripts/.local/share/scripts/switch_theme b/scripts/.local/share/scripts/switch_theme new file mode 100755 index 0000000..5a68071 --- /dev/null +++ b/scripts/.local/share/scripts/switch_theme @@ -0,0 +1,27 @@ +#!/bin/sh + +if [ $# -lt 1 ]; then + echo "Usage: switch_theme " + echo "mode: dark|light" + exit 1 +fi + +mode=$1 + +if [ "$mode" = "light" ]; then + emacsclient --eval "(load-theme 'doom-nord-light)" + sed -i "s/iceberg_dark/iceberg_light/" ~/.config/kitty/kitty.conf + sed -i "s/bg=dark/bg=light/" ~/.config/nvim/init.vim + sed -i "s/iceberg_dark/iceberg_light/" ~/.dotfiles/tmux/.tmux.conf + pkill kitty + tmux source-file ~/.tmux.conf + kitty --class tmux tmux a +else + emacsclient --eval "(load-theme 'doom-nord)" + sed -i "s/iceberg_light/iceberg_dark/" ~/.config/kitty/kitty.conf + sed -i "s/bg=light/bg=dark/" ~/.config/nvim/init.vim + sed -i "s/iceberg_light/iceberg_dark/" ~/.dotfiles/tmux/.tmux.conf + pkill kitty + tmux source-file ~/.tmux.conf + kitty --class tmux tmux a +fi diff --git a/sway/.config/sway/config b/sway/.config/sway/config index 1f1a6d3..366b64f 100644 --- a/sway/.config/sway/config +++ b/sway/.config/sway/config @@ -293,6 +293,19 @@ mode "$Pause-break" { bindsym Escape mode "default" } +# theme switcher menu +bindsym $mod+Shift+t mode "$Theme-switch" + +set $Theme-switch (l) light-theme, (d) dark-theme + +mode "$Theme-switch" { + bindsym l exec --no-startup-id ~/.local/share/scripts/switch_theme "light", mode "default" + bindsym d exec --no-startup-id ~/.local/share/scripts/switch_theme "dark", mode "default" + + bindsym Return mode "default" + bindsym Escape mode "default" +} + # lock screen on suspend set $lock_bg ~/Photos/Wallpapers/wallhaven-638719.png exec swayidle -w \ diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf index d1ea649..df8f9dd 100644 --- a/tmux/.tmux.conf +++ b/tmux/.tmux.conf @@ -74,4 +74,4 @@ bind -T root WheelUpPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "se bind -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M" # Colorscheme file -source-file ~/.tmux/iceberg.tmux.conf +source-file ~/.tmux/iceberg_dark.tmux.conf diff --git a/tmux/.tmux/iceberg.tmux.conf b/tmux/.tmux/iceberg.tmux.conf deleted file mode 100644 index f773f84..0000000 --- a/tmux/.tmux/iceberg.tmux.conf +++ /dev/null @@ -1,19 +0,0 @@ -# vim: ft=tmux -set -g status-justify "centre" -set -g status "on" -set -g status-left-style "none" -set -g message-command-style "fg=#c6c8d1,bg=#2e3244" -set -g status-right-style "none" -set -g pane-active-border-style "fg=#454b68" -set -g status-style "none,bg=#1e2132" -set -g message-style "fg=#c6c8d1,bg=#2e3244" -set -g pane-border-style "fg=#2e3244" -set -g status-right-length "100" -set -g status-left-length "100" -setw -g window-status-activity-style "none,fg=#454b68,bg=#1e2132" -setw -g window-status-separator "" -setw -g window-status-style "none,fg=#c6c8d1,bg=#1e2132" -set -g status-left "#[fg=#c6c8d1,bg=#454b68,bold] #S #[fg=#454b68,bg=#2e3244,nobold,nounderscore,noitalics]#[fg=#c6c8d1,bg=#1e2132] #[fg=#1e2132,bg=#1e2132,nobold,nounderscore,noitalics]" -set -g status-right "#[fg=#1e2132,bg=#1e2132,nobold,nounderscore,noitalics]#[fg=#c6c8d1,bg=#1e2132] #[fg=#2e3244,bg=#1e2132,nobold,nounderscore,noitalics]#[fg=#c6c8d1,bg=#2e3244] %b %d %Y #[fg=#454b68,bg=#2e3244,nobold,nounderscore,noitalics]#[fg=#c6c8d1,bg=#454b68,bold] %R #{prefix_highlight} " -setw -g window-status-format "#[fg=#1e2132,bg=#1e2132,nobold,nounderscore,noitalics] #[fg=#c6c8d1] #I  #W #[fg=#1e2132,bg=#1e2132,nobold,nounderscore,noitalics]" -setw -g window-status-current-format "#[fg=#1e2132,bg=#2e3244,nobold,nounderscore,noitalics]#[fg=#c6c8d1,bg=#2e3244] #I  #W #[fg=#2e3244,bg=#1e2132,nobold,nounderscore,noitalics]" diff --git a/tmux/.tmux/iceberg_dark.tmux.conf b/tmux/.tmux/iceberg_dark.tmux.conf new file mode 100644 index 0000000..50f209c --- /dev/null +++ b/tmux/.tmux/iceberg_dark.tmux.conf @@ -0,0 +1,10 @@ +set -g status-justify "centre" +set -g status "on" +set -g status-left-style "none" +set -g status-style "none,bg=#1e2132" +set -g status-left "#[bold] #S" +set -g pane-border-style "fg=#2e3244" +set -g pane-active-border-style "fg=#454b68" +setw -g window-status-style "none,fg=#c6c8d1,bg=#1e2132" +setw -g window-status-format " #[fg=#c6c8d1] #I - #W " +setw -g window-status-current-format " #[fg=#c6c8d1,bg=#2e3244,bold] #I - #W " diff --git a/tmux/.tmux/iceberg_light.tmux.conf b/tmux/.tmux/iceberg_light.tmux.conf new file mode 100644 index 0000000..5240328 --- /dev/null +++ b/tmux/.tmux/iceberg_light.tmux.conf @@ -0,0 +1,10 @@ +set -g status-justify "centre" +set -g status "on" +set -g status-left-style "none" +set -g status-style "none,bg=#d2d4dd" +set -g status-left "#[bold] #S" +set -g pane-border-style "fg=#c6c8d1" +set -g pane-active-border-style "fg=#33374c" +setw -g window-status-style "none,fg=#33374c,bg=#d2d4dd" +setw -g window-status-format " #[fg=#afafaf] #I - #W " +setw -g window-status-current-format " #[fg=#282a2e,bold] #I - #W "