Skip to content

Commit

Permalink
fix: allow for dynamic colors in status modules (#411), fixes issue #407
Browse files Browse the repository at this point in the history


* fix: allow also dynamic background when setting @catppuccin_${MODULE_NAME}_color
  • Loading branch information
dreknix authored Oct 25, 2024
1 parent 61f08ce commit 5e273e4
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 23 deletions.
2 changes: 1 addition & 1 deletion status/battery.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set -ogq @batt_icon_status_unknown "󰂑"
set -ogq @batt_icon_status_attached "󱈑"

set -ogq "@catppuccin_${MODULE_NAME}_icon" "#{l:#{battery_icon}} "
set -ogq "@catppuccin_${MODULE_NAME}_color" "#{@thm_lavender}"
set -ogqF "@catppuccin_${MODULE_NAME}_color" "#{E:@thm_lavender}"
set -ogq "@catppuccin_${MODULE_NAME}_text" " #{l:#{battery_percentage}}"

source -F "#{d:current_file}/../utils/status_module.conf"
16 changes: 11 additions & 5 deletions status/cpu.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# vim:set ft=tmux:
%hidden MODULE_NAME="cpu"

set -ogq @cpu_low_bg_color "#[bg=none]"
set -ogq @cpu_medium_bg_color "#[bg=none]"
set -ogq @cpu_high_bg_color "#[bg=#{@thm_red},fg=#{@thm_crust}]"
set -ogq @cpu_low_fg_color "#{E:@thm_fg}"
set -ogq @cpu_medium_fg_color "#{E:@thm_fg}"
set -ogq @cpu_high_fg_color "#{E:@thm_crust}"

set -ogq @cpu_low_bg_color "#{E:@catppuccin_status_module_text_bg}"
set -ogq @cpu_medium_bg_color "#{E:@catppuccin_status_module_text_bg}"
set -ogq @cpu_high_bg_color "#{E:@thm_red}"

set -ogq "@catppuccin_${MODULE_NAME}_icon" " "
set -ogq "@catppuccin_${MODULE_NAME}_color" "#{@thm_yellow}"
set -ogq "@catppuccin_${MODULE_NAME}_text" " #{l:#{cpu_bg_color}#{cpu_percentage}}"
set -ogqF "@catppuccin_${MODULE_NAME}_color" "#{E:@thm_yellow}"
set -ogq "@catppuccin_status_${MODULE_NAME}_text_fg" "#{l:#{cpu_fg_color}}"
set -ogq "@catppuccin_status_${MODULE_NAME}_text_bg" "#{l:#{cpu_bg_color}}"
set -ogq "@catppuccin_${MODULE_NAME}_text" " #{l:#{cpu_percentage}}"

source -F "#{d:current_file}/../utils/status_module.conf"
2 changes: 1 addition & 1 deletion status/gitmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Requires https://github.com/arl/gitmux
set -ogq "@catppuccin_${MODULE_NAME}_icon" "󰊢 "
set -ogqF "@catppuccin_${MODULE_NAME}_color" "#{@thm_teal}"
set -ogqF "@catppuccin_${MODULE_NAME}_color" "#{E:@thm_teal}"
set -gq "@catppuccin_${MODULE_NAME}_text" ' #(gitmux -cfg $HOME/.gitmux.conf "#{pane_current_path}")'

source -F "#{d:current_file}/../utils/status_module.conf"
6 changes: 3 additions & 3 deletions status/kube.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# Requires https://github.com/jonmosco/kube-tmux

set -ogq "@catppuccin_${MODULE_NAME}_icon" "󱃾 "
set -ogqF "@catppuccin_${MODULE_NAME}_color" "#{@thm_blue}"
set -ogqF "@catppuccin_kube_context_color" "#{@thm_red}"
set -ogqF "@catppuccin_kube_namespace_color" "#{@thm_sky}"
set -ogqF "@catppuccin_${MODULE_NAME}_color" "#{E:@thm_blue}"
set -ogqF "@catppuccin_kube_context_color" "#{E:@thm_red}"
set -ogqF "@catppuccin_kube_namespace_color" "#{E:@thm_sky}"
set -ogq "@catppuccin_${MODULE_NAME}_text" \
" #(${TMUX_PLUGIN_MANAGER_PATH}kube-tmux/kube.tmux 250 #{@catppuccin_kube_context_color} #{@catppuccin_kube_namespace_color})"

Expand Down
2 changes: 1 addition & 1 deletion status/load.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%hidden MODULE_NAME="load"

set -ogq "@catppuccin_${MODULE_NAME}_icon" "󰊚 "
set -ogq "@catppuccin_${MODULE_NAME}_color" "#{@thm_blue}"
set -ogqF "@catppuccin_${MODULE_NAME}_color" "#{E:@thm_blue}"
set -ogq "@catppuccin_${MODULE_NAME}_text" " #{load_full}"

source -F "#{d:current_file}/../utils/status_module.conf"
2 changes: 1 addition & 1 deletion status/session.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%hidden MODULE_NAME="session"

set -ogq "@catppuccin_${MODULE_NAME}_icon" " "
set -ogq "@catppuccin_${MODULE_NAME}_color" "##{?client_prefix,#{E:@thm_red},#{E:@thm_green}}"
set -ogq "@catppuccin_${MODULE_NAME}_color" "#{?client_prefix,#{E:@thm_red},#{E:@thm_green}}"
set -ogq "@catppuccin_${MODULE_NAME}_text" " #S"

source -F "#{d:current_file}/../utils/status_module.conf"
2 changes: 1 addition & 1 deletion status/uptime.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%hidden MODULE_NAME="uptime"

set -ogq @catppuccin_uptime_icon "󰔟 "
set -ogqF @catppuccin_uptime_color "#{@thm_sapphire}"
set -ogqF @catppuccin_uptime_color "#{E:@thm_sapphire}"
set -ogq @catppuccin_uptime_text " #(uptime | sed 's/^[^,]*up *//; s/, *[[:digit:]]* user.*//; s/ day.*, */d /; s/:/h /; s/ min//; s/$/m/')"

source -F "#{d:current_file}/../utils/status_module.conf"
2 changes: 1 addition & 1 deletion status/user.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%hidden MODULE_NAME="user"

set -ogq @catppuccin_user_icon " "
set -ogqF @catppuccin_user_color "#{@thm_sky}"
set -ogqF @catppuccin_user_color "#{E:@thm_sky}"
set -ogq @catppuccin_user_text " #(whoami)"

source -F "#{d:current_file}/../utils/status_module.conf"
2 changes: 1 addition & 1 deletion status/weather.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Requires https://github.com/xamut/tmux-weather.

set -ogq @catppuccin_weather_icon " "
set -ogqF @catppuccin_weather_color "#{@thm_yellow}"
set -ogqF @catppuccin_weather_color "#{E:@thm_yellow}"
set -ogq @catppuccin_weather_text " #{l:#{weather}}"

source -F "#{d:current_file}/../utils/status_module.conf"
2 changes: 1 addition & 1 deletion tests/cpu_module_expected.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
E:@catppuccin_status_cpu #[fg=#f9e2af]#[fg=#11111b,bg=#f9e2af] #[fg=#cdd6f4,bg=#313244] #{cpu_bg_color}#{cpu_percentage}#[reverse]█#[noreverse]
E:@catppuccin_status_cpu #[fg=#f9e2af]#[fg=#11111b,bg=#f9e2af] #[fg=#{cpu_fg_color},bg=#{cpu_bg_color}] #{cpu_percentage}#[reverse]█#[noreverse]
17 changes: 10 additions & 7 deletions utils/status_module.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,30 @@ set -gqF @_ctp_connect_style \
# - fg: @catppuccin_status_[module]_text_fg [default = foreground]
# - bg: @catppuccin_status_[module]_text_bg [default = @catppuccin_status_module_text_bg]

set -ogq "@catppuccin_status_${MODULE_NAME}_icon_fg" "#{@thm_crust}"
set -ogq "@catppuccin_status_${MODULE_NAME}_text_fg" "#{@thm_fg}"
set -ogqF "@catppuccin_status_${MODULE_NAME}_icon_bg" "#{@catppuccin_${MODULE_NAME}_color}"
set -ogqF "@catppuccin_status_${MODULE_NAME}_icon_fg" "#{E:@thm_crust}"
set -ogqF "@catppuccin_status_${MODULE_NAME}_text_fg" "#{E:@thm_fg}"

%if "#{==:#{@catppuccin_status_${MODULE_NAME}_icon_bg},}"
set -gqF "@catppuccin_status_${MODULE_NAME}_icon_bg" "#{@catppuccin_${MODULE_NAME}_color}"
%endif

%if "#{==:#{@catppuccin_status_${MODULE_NAME}_text_bg},}"
set -gqF @_ctp_module_text_bg "#{E:@catppuccin_status_module_text_bg}"
%else
set -gqF @_ctp_module_text_bg "#{E:@catppuccin_status_${MODULE_NAME}_text_bg}"
set -gqF @_ctp_module_text_bg "#{@catppuccin_status_${MODULE_NAME}_text_bg}"
%endif

set -gF "@catppuccin_status_${MODULE_NAME}" \
"#[fg=#{E:@catppuccin_status_${MODULE_NAME}_icon_bg}]#{@_ctp_connect_style}#{@catppuccin_status_left_separator}"
"#[fg=#{@catppuccin_status_${MODULE_NAME}_icon_bg}]#{@_ctp_connect_style}#{@catppuccin_status_left_separator}"

set -agF "@catppuccin_status_${MODULE_NAME}" \
"#[fg=#{E:@catppuccin_status_${MODULE_NAME}_icon_fg},bg=#{E:@catppuccin_status_${MODULE_NAME}_icon_bg}]#{@catppuccin_${MODULE_NAME}_icon}"
"#[fg=#{@catppuccin_status_${MODULE_NAME}_icon_fg},bg=#{@catppuccin_status_${MODULE_NAME}_icon_bg}]#{@catppuccin_${MODULE_NAME}_icon}"

set -agF "@catppuccin_status_${MODULE_NAME}" \
"#{@catppuccin_status_middle_separator}"

set -agF "@catppuccin_status_${MODULE_NAME}" \
"#[fg=#{E:@catppuccin_status_${MODULE_NAME}_text_fg},bg=#{@_ctp_module_text_bg}]"
"#[fg=#{@catppuccin_status_${MODULE_NAME}_text_fg},bg=#{@_ctp_module_text_bg}]"

set -ag "@catppuccin_status_${MODULE_NAME}" "#{E:@catppuccin_${MODULE_NAME}_text}"

Expand Down

0 comments on commit 5e273e4

Please sign in to comment.