From 975bff000f6e60ac16893a3b85cea432efc0a4e2 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Mon, 4 Mar 2024 21:18:35 -0500 Subject: [PATCH] ADD scripts for changing light and dark themes --- dot_bin/executable_alacritty_theme | 24 ++++++++++++++++++++++ dot_bin/executable_themectl | 22 ++++++++++++++++++++ dot_config/X11/xinitrc.tmpl | 2 +- dot_config/alacritty/alacritty.toml.light | 14 ++++++------- dot_config/tmux/scripts/executable_tmuxctl | 9 +++++++- dot_config/tmux/tmux.conf | 22 ++++++++++++-------- 6 files changed, 75 insertions(+), 18 deletions(-) create mode 100644 dot_bin/executable_alacritty_theme create mode 100644 dot_bin/executable_themectl diff --git a/dot_bin/executable_alacritty_theme b/dot_bin/executable_alacritty_theme new file mode 100644 index 0000000..e3784d1 --- /dev/null +++ b/dot_bin/executable_alacritty_theme @@ -0,0 +1,24 @@ +#!/bin/bash + +config=$XDG_CONFIG_HOME/alacritty/alacritty.toml +light=$config.light +dark=$config.dark + +if [[ "$1" == "toggle" ]]; then + current=$(readlink $config) + if [ $current == $light ]; then + ln -sf $dark $config + elif [ $current == $dark ]; then + ln -sf $light $config + else + echo 'Invalid link' + exit 1 + fi +elif [[ "$1" == "dark" ]]; then + ln -sf $dark $config +elif [[ "$1" == "light" ]]; then + ln -sf $light $config +else + echo 'Invalid command' + exit 1 +fi diff --git a/dot_bin/executable_themectl b/dot_bin/executable_themectl new file mode 100644 index 0000000..27300e0 --- /dev/null +++ b/dot_bin/executable_themectl @@ -0,0 +1,22 @@ +#!/bin/bash + +if [[ "$1" == "toggle" ]]; then + emacs_ctl theme toggle + tmuxctl toggle-theme + alacritty_theme toggle +elif [[ "$1" == "dark" ]]; then + emacs_ctl theme dark + tmuxctl dark-theme + alacritty_theme dark +elif [[ "$1" == "light" ]]; then + emacs_ctl theme light + tmuxctl light-theme + alacritty_theme light +else + echo 'Invalid command' + exit 1 +fi + +if [[ "$2" == "force" ]]; then + emacs_ctl restart +fi diff --git a/dot_config/X11/xinitrc.tmpl b/dot_config/X11/xinitrc.tmpl index d47c64c..b59c2c2 100644 --- a/dot_config/X11/xinitrc.tmpl +++ b/dot_config/X11/xinitrc.tmpl @@ -33,7 +33,7 @@ greenclip daemon & redshift > /dev/null 2>&1 & dunst & {{ if .development.emacs -}} -emacs-start & +emacs_ctl start & {{- end }} {{ if .features.seafile -}} seafile-applet > /dev/null 2>&1 & diff --git a/dot_config/alacritty/alacritty.toml.light b/dot_config/alacritty/alacritty.toml.light index c61fa93..9577004 100644 --- a/dot_config/alacritty/alacritty.toml.light +++ b/dot_config/alacritty/alacritty.toml.light @@ -11,20 +11,20 @@ draw_bold_text_with_bright_colors = true [colors.normal] black = "#000000" -red = "#a00606" -green = "#007700" +red = "#cc0606" +green = "#008000" yellow = "#969600" blue = "#0020aa" magenta = "#cc20cc" cyan = "#20cccc" -white = "#ffffff" +white = "#fcfcfc" [colors.bright] black = "#333333" -red = "#dd3030" -green = "#08aa08" -yellow = "#aaaa10" +red = "#dd1010" +green = "#08a008" +yellow = "#baba00" blue = "#0040bb" magenta = "#ff60ff" -cyan = "#1ebbbb" +cyan = "#00b1b1" white = "#ffffff" diff --git a/dot_config/tmux/scripts/executable_tmuxctl b/dot_config/tmux/scripts/executable_tmuxctl index d411887..4b54259 100644 --- a/dot_config/tmux/scripts/executable_tmuxctl +++ b/dot_config/tmux/scripts/executable_tmuxctl @@ -9,8 +9,15 @@ elif [[ "$1" == "start" ]]; then tmux new-session -s "$session_name" -d elif [[ "$1" == "stop" ]]; then tmux kill-session -t "$session_name" +elif [[ "$1" == "toggle-theme" ]]; then + [ $(tmux show -v @dark-theme) == 0 ] && theme=1 || theme=0 + tmux set @dark-theme $theme +elif [[ "$1" == "dark-theme" ]]; then + tmux set @dark-theme 1 +elif [[ "$1" == "light-theme" ]]; then + tmux set @dark-theme 0 else - echo 'Command must be either "start" or "stop"' + echo 'Invalid command' exit 1 fi diff --git a/dot_config/tmux/tmux.conf b/dot_config/tmux/tmux.conf index ff43be2..1dc1f65 100644 --- a/dot_config/tmux/tmux.conf +++ b/dot_config/tmux/tmux.conf @@ -3,6 +3,8 @@ run-shell 'tmux setenv -g TMUX_VERSION $(tmux -V | \ sed -En "s/^tmux[^0-9]*([.0-9]+).*/\1/p")' +set -g @dark-theme 0 + # use vi bindings set -g status-keys vi set -g mode-keys vi @@ -77,15 +79,17 @@ bind C-c copy-mode # theme +# TODO this feel sloppy (don't use an ENVVAR) status_sep="#[fg=#888888]|#[default]" set -g status-interval 1 set -g status-left "#h:#S $status_sep " set -g status-left-length 32 -set -g status-style "fg=#cccccc,bg=#444444" -set -g window-status-style "fg=#9f9f9f" -set -g window-status-activity-style "fg=#9f9f9f" -set -g window-status-current-style "fg=#000000 bold,bg=#00ff00" + +set -g status-style "#{?@dark-theme,fg=##cccccc#,bg=##444444,fg=##2c2c2c#,bg=##d6d6d6}" +set -g window-status-style "#{?@dark-theme,fg=##9f9f9f,fg=##909090}" +set -g window-status-activity-style "#{?@dark-theme,fg=##9f9f9f,fg=##808080}" +set -g window-status-current-style "#{?@dark-theme,fg=##000000 bold#,bg=##00ff00,fg=##000000 bold#,bg=##00dd00}" set -g window-status-separator "" set -g window-status-format " #{?window_activity_flag,##,}#I-#W " @@ -94,13 +98,13 @@ set -g window-status-current-format " #I-#W " set -g visual-activity off set -g monitor-activity on -set -g pane-border-style "fg=#444444" +set -g pane-border-style "#{?@dark-theme,fg=##444444,fg=##d6d6d6}" set -g pane-active-border-style "fg=#aaaaaa" if-shell -b '[ "$(echo "$TMUX_VERSION >= 3.2" | bc)" = 1 ]' \ "set -g pane-border-lines heavy" -set -g message-style "fg=#ffffaa,bg=#666600" +set -g message-style "#{?@dark-theme,fg=##ffffaa#,bg=##666600,fg=##333300#,bg=##dddd66}" set -g pane-border-status off @@ -112,9 +116,9 @@ if-shell -b '[ "$(echo "$TMUX_VERSION >= 3.2" | bc)" = 1 ]' \ bind -T root F12 \ set prefix None \;\ set key-table off \;\ - set status-style "fg=#aaaaaa,bg=#666666" \;\ - set window-status-style "fg=#777777" \;\ - set window-status-current-style "fg=#666666 bold,bg=#999999" \;\ + set status-style "#{?@dark-mode,fg=##aaaaaa#,bg=##666666,fg=##1c1c1c#,bg=##787878}" \;\ + set window-status-style "#{?@dark-mode,fg=##777777,fg=##2c2c2c}" \;\ + set window-status-current-style "#{?@dark-mode,fg=##666666 bold#,bg=##999999,fg=##444444 bold#,bg=##999999}" \;\ if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\ refresh-client -S \;\