Skip to content

Commit

Permalink
feat: improve transparent background
Browse files Browse the repository at this point in the history
  • Loading branch information
89iuv committed Mar 27, 2024
1 parent e2d3456 commit 6ba27b4
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 79 deletions.
42 changes: 17 additions & 25 deletions builder/module_builder.sh
Original file line number Diff line number Diff line change
@@ -1,68 +1,60 @@
#!/bin/sh

build_status_module() {
local index=$1
local icon=$2
local color=$3
local text=$4
local index="$1"
local icon="$2"
local color="$3"
local text="$4"

if [ "$status_fill" = "icon" ]
then
if [ "$status_fill" = "icon" ]; then
local show_left_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator"

local show_icon="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$icon "
local show_text="#[fg=$thm_fg,bg=$thm_gray] $text"

local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator"

if [ "$status_connect_separator" = "yes" ]
then
if [ "$status_connect_separator" = "yes" ]; then
local show_left_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator"
local show_right_separator="#[fg=$thm_gray,bg=$thm_gray,nobold,nounderscore,noitalics]$status_right_separator"

else
local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator"
local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator"
local show_left_separator="#[fg=$color,bg=default,nobold,nounderscore,noitalics]$status_left_separator"
local show_right_separator="#[fg=$thm_gray,bg=default,nobold,nounderscore,noitalics]$status_right_separator"
fi

fi

if [ "$status_fill" = "all" ]
then
if [ "$status_fill" = "all" ]; then
local show_left_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator"

local show_icon="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$icon "
local show_text="#[fg=$thm_bg,bg=$color]$text"

local show_right_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_right_separator"

if [ "$status_connect_separator" = "yes" ]
then
if [ "$status_connect_separator" = "yes" ]; then
local show_left_separator="#[fg=$color,nobold,nounderscore,noitalics]$status_left_separator"
local show_right_separator="#[fg=$color,bg=$color,nobold,nounderscore,noitalics]$status_right_separator"

else
local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator"
local show_right_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator"
local show_left_separator="#[fg=$color,bg=default,nobold,nounderscore,noitalics]$status_left_separator"
local show_right_separator="#[fg=$color,bg=default,nobold,nounderscore,noitalics]$status_right_separator"
fi

fi

if [ "$status_right_separator_inverse" = "yes" ]
then
if [ "$status_connect_separator" = "yes" ]
then
if [ "$status_right_separator_inverse" = "yes" ]; then
if [ "$status_connect_separator" = "yes" ]; then
local show_right_separator="#[fg=$thm_gray,bg=$color,nobold,nounderscore,noitalics]$status_right_separator"
else
local show_right_separator="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$status_right_separator"
local show_right_separator="#[fg=$thm_bg,bg=default,nobold,nounderscore,noitalics]$status_right_separator"
fi
fi

if [ $(($index)) -eq 0 ]
then
local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator"
if [ $(($index)) -eq 0 ]; then
local show_left_separator="#[fg=$color,bg=default,nobold,nounderscore,noitalics]$status_left_separator"
fi

echo "$show_left_separator$show_icon$show_text$show_right_separator"
}

91 changes: 56 additions & 35 deletions builder/window_builder.sh
Original file line number Diff line number Diff line change
@@ -1,67 +1,90 @@
#!/bin/sh

build_window_format() {
local number=$1
local color=$2
local background=$3
local text=$4
local fill=$5

if [ "$window_status_enable" = "yes" ]
then
local icon="$( build_window_icon )"
local number="$1"
local color="$2"
local background="$3"
local text="$4"
local fill="$5"

if [ "$window_status_enable" = "yes" ]; then
local icon="$(build_window_icon)"
text="$text$icon"
fi

if [ "$fill" = "none" ]
then
local show_left_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
if [ "$fill" = "none" ]; then
local show_number="#[fg=$thm_fg,bg=$thm_gray]$number"
local show_middle_separator="#[fg=$thm_fg,bg=$thm_gray,nobold,nounderscore,noitalics]$window_middle_separator"
local show_text="#[fg=$thm_fg,bg=$thm_gray]$text"
local show_right_separator="#[fg=$thm_gray,bg=$thm_bg]$window_right_separator"

if [ "$status_connect_separator" = "yes" ]; then
local show_left_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
local show_right_separator="#[fg=$thm_gray,bg=$thm_bg]$window_right_separator"

else
local show_left_separator="#[fg=$thm_gray,bg=default,nobold,nounderscore,noitalics]$window_left_separator"
local show_right_separator="#[fg=$thm_gray,bg=default]$window_right_separator"

fi

fi

if [ "$fill" = "all" ]
then
local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
if [ "$fill" = "all" ]; then
local show_number="#[fg=$background,bg=$color]$number"
local show_middle_separator="#[fg=$background,bg=$color,nobold,nounderscore,noitalics]$window_middle_separator"
local show_text="#[fg=$background,bg=$color]$text"
local show_right_separator="#[fg=$color,bg=$thm_bg]$window_right_separator"

if [ "$status_connect_separator" = "yes" ]; then
local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
local show_right_separator="#[fg=$color,bg=$thm_bg]$window_right_separator"

else
local show_left_separator="#[fg=$color,bg=default,nobold,nounderscore,noitalics]$window_left_separator"
local show_right_separator="#[fg=$color,bg=default]$window_right_separator"

fi

fi

if [ "$fill" = "number" ]
then
if [ "$fill" = "number" ]; then
local show_number="#[fg=$background,bg=$color]$number"
local show_middle_separator="#[fg=$color,bg=$background,nobold,nounderscore,noitalics]$window_middle_separator"
local show_text="#[fg=$thm_fg,bg=$background]$text"

if [ "$window_number_position" = "right" ]
then
local show_left_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
local show_right_separator="#[fg=$color,bg=$thm_bg]$window_right_separator"
if [ "$window_number_position" = "right" ]; then
if [ "$status_connect_separator" = "yes" ]; then
local show_left_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
local show_right_separator="#[fg=$color,bg=$thm_bg]$window_right_separator"

else
local show_left_separator="#[fg=$background,bg=default,nobold,nounderscore,noitalics]$window_left_separator"
local show_right_separator="#[fg=$color,bg=default]$window_right_separator"

fi
fi

if [ "$window_number_position" = "left" ]
then
local show_right_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$window_right_separator"
local show_left_separator="#[fg=$color,bg=$thm_bg]$window_left_separator"
if [ "$window_number_position" = "left" ]; then
if [ "$status_connect_separator" = "yes" ]; then
local show_right_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$window_right_separator"
local show_left_separator="#[fg=$color,bg=$thm_bg]$window_left_separator"

else
local show_right_separator="#[fg=$background,bg=default,nobold,nounderscore,noitalics]$window_right_separator"
local show_left_separator="#[fg=$color,bg=default]$window_left_separator"

fi

fi

fi

local final_window_format

if [ "$window_number_position" = "right" ]
then
if [ "$window_number_position" = "right" ]; then
final_window_format="$show_left_separator$show_text$show_middle_separator$show_number$show_right_separator"
fi

if [ "$window_number_position" = "left" ]
then
if [ "$window_number_position" = "left" ]; then
final_window_format="$show_left_separator$show_number$show_middle_separator$show_text$show_right_separator"
fi

Expand All @@ -78,8 +101,7 @@ build_window_icon() {
local custom_icon_window_activity=$(get_tmux_option "@catppuccin_icon_window_activity" "󱅫")
local custom_icon_window_bell=$(get_tmux_option "@catppuccin_icon_window_bell" "󰂞")

if [ "$window_status_icon_enable" = "yes" ]
then
if [ "$window_status_icon_enable" = "yes" ]; then
# #!~[*-]MZ
local show_window_status=""
show_window_status+="#{?window_activity_flag, ${custom_icon_window_activity},}"
Expand All @@ -92,8 +114,7 @@ build_window_icon() {

fi

if [ "$window_status_icon_enable" = "no" ]
then
if [ "$window_status_icon_enable" = "no" ]; then
local show_window_status=" #F"
fi

Expand Down
31 changes: 12 additions & 19 deletions catppuccin.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ source "${PLUGIN_DIR}/builder/pane_builder.sh"
source "${PLUGIN_DIR}/utils/tmux_utils.sh"
source "${PLUGIN_DIR}/utils/module_utils.sh"


main() {
# Aggregate all commands in one array
local tmux_commands=()
Expand All @@ -29,14 +28,14 @@ main() {
# shellcheck source=catppuccin-frappe.tmuxtheme
# https://github.com/dylanaraps/pure-sh-bible#parsing-a-keyval-file
while IFS='=' read -r key val; do
# Skip over lines containing comments.
# (Lines starting with '#').
[ "${key##\#*}" ] || continue
# Skip over lines containing comments.
# (Lines starting with '#').
[ "${key##\#*}" ] || continue

# '$key' stores the key.
# '$val' stores the value.
eval "local $key"="$val"
done < "${PLUGIN_DIR}/catppuccin-${theme}.tmuxtheme"
# '$key' stores the key.
# '$val' stores the value.
eval "local $key"="$val"
done <"${PLUGIN_DIR}/catppuccin-${theme}.tmuxtheme"

# status general
local status_default=$(get_tmux_option "@catppuccin_status_default" "on")
Expand All @@ -46,12 +45,10 @@ main() {
set status-justify "$status_justify"

local status_background=$(get_tmux_option "@catppuccin_status_background" "theme")
if [ "${status_background}" = "theme" ];
then
if [ "${status_background}" = "theme" ]; then
set status-bg "${thm_bg}"
else
if [ "${status_background}" = "default" ]
then
if [ "${status_background}" = "default" ]; then
set status-style bg=default
else
set status-bg "${status_background}"
Expand All @@ -61,7 +58,6 @@ main() {
set status-left-length "100"
set status-right-length "100"


# messages
set message-style "fg=${thm_cyan},bg=${thm_gray},align=centre"
set message-command-style "fg=${thm_cyan},bg=${thm_gray},align=centre"
Expand All @@ -70,9 +66,9 @@ main() {
local pane_status_enable=$(get_tmux_option "@catppuccin_pane_status_enabled" "no") # yes
local pane_border_status=$(get_tmux_option "@catppuccin_pane_border_status" "off") # bottom
local pane_border_style=$(get_tmux_option "@catppuccin_pane_border_style" "fg=${thm_gray}")
local pane_active_border_style=$(\
local pane_active_border_style=$(
get_tmux_option "@catppuccin_pane_active_border_style" \
"#{?pane_in_mode,fg=${thm_yellow},#{?pane_synchronized,fg=${thm_magenta},fg=${thm_orange}}}"
"#{?pane_in_mode,fg=${thm_yellow},#{?pane_synchronized,fg=${thm_magenta},fg=${thm_orange}}}"
)
local pane_left_separator=$(get_tmux_option "@catppuccin_pane_left_separator" "")
local pane_middle_separator=$(get_tmux_option "@catppuccin_pane_middle_separator" "")
Expand All @@ -89,14 +85,11 @@ main() {
local window_status_separator=$(get_tmux_option "@catppuccin_window_separator" "")
setw window-status-separator "$window_status_separator"

setw window-status-activity-style "fg=${thm_fg},bg=${thm_bg},none"
setw window-status-style "fg=${thm_fg},bg=${thm_bg},none"

local window_left_separator=$(get_tmux_option "@catppuccin_window_left_separator" "")
local window_right_separator=$(get_tmux_option "@catppuccin_window_right_separator" "")
local window_middle_separator=$(get_tmux_option "@catppuccin_window_middle_separator" "")
local window_number_position=$(get_tmux_option "@catppuccin_window_number_position" "left") # right, left
local window_status_enable=$(get_tmux_option "@catppuccin_window_status_enable" "no") # right, left
local window_status_enable=$(get_tmux_option "@catppuccin_window_status_enable" "no") # right, left

local window_format=$(load_modules "window_default_format" "$modules_custom_path" "$modules_window_path")
setw window-status-format "$window_format"
Expand Down

0 comments on commit 6ba27b4

Please sign in to comment.