Skip to content

Commit

Permalink
Merge pull request #44 from cameronr/transparent
Browse files Browse the repository at this point in the history
feat:  fixes #37 transparency support
  • Loading branch information
fabioluciano authored Oct 1, 2024
2 parents 1199b24 + ac70e42 commit 4ba288a
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 9 deletions.
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

## Features

- [Transparency support](#Transparency-examples)

## Plugins

- **Datetime** - Show datetime;
Expand Down Expand Up @@ -116,7 +118,7 @@ Shows battery charging status (charging or discharging) and battery percentage.

tmux.conf

```
```bash
set -g @plugin 'tmux-plugins/tpm'

set -g @plugin 'tmux-plugins/tmux-pain-control'
Expand All @@ -134,6 +136,35 @@ set -g @theme_plugins 'datetime,weather,playerctl,yay'
run '~/.tmux/plugins/tpm/tpm'
```

### Transparency examples

Enable transparency with default separators:

```bash
### Enable transparency
set -g @theme_transparent_status_bar 'true'
```

![Screenshot 2024-09-07 at 12 41 12](https://github.com/user-attachments/assets/56287ccb-9be9-4aa5-a2ab-ec48d2b2d08a)

####

Can also use custom separators:

```bash
### Enable transparency
set -g @theme_left_separator ''
set -g @theme_right_separator ''
set -g @theme_transparent_status_bar 'true'
set -g @theme_transparent_left_separator_inverse ''
set -g @theme_transparent_right_separator_inverse ''

```

![Screenshot 2024-09-07 at 12 39 35](https://github.com/user-attachments/assets/a33417b1-34e0-4212-952e-7ef1e240e943)



[features]: #features
[screenshots]: #screenshots
[install]: #install
Expand Down
21 changes: 20 additions & 1 deletion src/theme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ border_style_active_pane=$(get_tmux_option "@theme_active_pane_border_style" "${
border_style_inactive_pane=$(get_tmux_option "@theme_inactive_pane_border_style" "${PALLETE[bg_highlight]}")
left_separator=$(get_tmux_option "@theme_left_separator" "")
right_separator=$(get_tmux_option "@theme_right_separator" "")
transparent=$(get_tmux_option "@theme_transparent_status_bar" "false")

if [ "$transparent" = "true" ]; then
left_separator_inverse=$(get_tmux_option "@theme_transparent_left_separator_inverse" "")
right_separator_inverse=$(get_tmux_option "@theme_transparent_right_separator_inverse" "")
fi

window_with_activity_style=$(get_tmux_option "@theme_window_with_activity_style" "italics")
window_status_bell_style=$(get_tmux_option "@theme_status_bell_style" "bold")
Expand All @@ -35,7 +41,11 @@ tmux set-window-option -g window-status-bell-style "${window_status_bell_style}"
tmux set-option -g message-style "bg=${PALLETE[red]},fg=${PALLETE[bg_dark]}"

# status bar
tmux set-option -g status-style "bg=${PALLETE[bg_highlight]},fg=${PALLETE[white]}"
status_bar_bg=${PALLETE[bg_highlight]}
if [ "$transparent" = "true" ]; then
status_bar_bg="default"
fi
tmux set-option -g status-style "bg=${status_bar_bg},fg=${PALLETE[white]}"

# border color
tmux set-option -g pane-active-border-style "fg=$border_style_active_pane"
Expand Down Expand Up @@ -89,6 +99,15 @@ if [ "$theme_disable_plugins" -ne 1 ]; then
separator_end="#[fg=${PALLETE[bg_highlight]},bg=${accent_color}]${right_separator}#[none]"
separator_icon_start="#[fg=${accent_color_icon},bg=${PALLETE[bg_highlight]}]${right_separator}#[none]"
separator_icon_end="#[fg=${accent_color},bg=${accent_color_icon}]${right_separator}#[none]"
if [ "$transparent" = "true" ]; then
separator_icon_start="#[fg=${accent_color_icon},bg=default]${right_separator}#[none]"
separator_icon_end="#[fg=${accent_color},bg=${accent_color_icon}]${right_separator}#[none]"
separator_end="#[fg=${accent_color},bg=default]${right_separator_inverse}#[none]"
else
separator_icon_start="#[fg=${accent_color_icon},bg=${PALLETE[bg_highlight]}]${right_separator}#[none]"
separator_icon_end="#[fg=${accent_color},bg=${accent_color_icon}]${right_separator}#[none]"
separator_end="#[fg=${PALLETE[bg_highlight]},bg=${accent_color}]${right_separator}#[none]"
fi

plugin_output_string=""

Expand Down
30 changes: 23 additions & 7 deletions src/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ function get_tmux_option() {
function generate_left_side_string() {

session_icon=$(get_tmux_option "@theme_session_icon" "⋅")
local separator_end="#[bg=${PALLETE[bg_highlight]}]#{?client_prefix,#[fg=${PALLETE[yellow]}],#[fg=${PALLETE[green]}]}${left_separator:?}#[none]"
if [ "$transparent" = "true" ]; then
local separator_end="#[bg=default]#{?client_prefix,#[fg=${PALLETE[yellow]}],#[fg=${PALLETE[green]}]}${left_separator:?}#[none]"
else
local separator_end="#[bg=${PALLETE[bg_highlight]}]#{?client_prefix,#[fg=${PALLETE[yellow]}],#[fg=${PALLETE[green]}]}${left_separator:?}#[none]"
fi

echo "#[fg=${PALLETE[fg_gutter]},bold]#{?client_prefix,#[bg=${PALLETE[yellow]}],#[bg=${PALLETE[green]}]} ${session_icon} #S ${separator_end}"
}
Expand All @@ -25,9 +29,15 @@ function generate_inactive_window_string() {
inactive_window_icon=$(get_tmux_option "@theme_plugin_inactive_window_icon" "")
zoomed_window_icon=$(get_tmux_option "@theme_plugin_zoomed_window_icon" "")

local separator_start="#[bg=${PALLETE['dark5']},fg=${PALLETE['bg_highlight']}]${left_separator:?}#[none]"
local separator_internal="#[bg=${PALLETE['dark3']},fg=${PALLETE['dark5']}]${left_separator:?}#[none]"
local separator_end="#[bg=${PALLETE[bg_highlight]},fg=${PALLETE['dark3']}]${left_separator:?}#[none]"
if [ "$transparent" = "true" ]; then
local separator_start="#[bg=default,fg=${PALLETE['dark5']}]${left_separator_inverse}#[bg=${PALLETE['dark5']},fg=${PALLETE['bg_highlight']}]"
local separator_internal="#[bg=${PALLETE['dark3']},fg=${PALLETE['dark5']}]${left_separator:?}#[none]"
local separator_end="#[bg=default,fg=${PALLETE['dark3']}]${left_separator:?}#[none]"
else
local separator_start="#[bg=${PALLETE['dark5']},fg=${PALLETE['bg_highlight']}]${left_separator:?}#[none]"
local separator_internal="#[bg=${PALLETE['dark3']},fg=${PALLETE['dark5']}]${left_separator:?}#[none]"
local separator_end="#[bg=${PALLETE[bg_highlight]},fg=${PALLETE['dark3']}]${left_separator:?}#[none]"
fi

echo "${separator_start}#[fg=${PALLETE[white]}]#I${separator_internal}#[fg=${PALLETE[white]}] #{?window_zoomed_flag,$zoomed_window_icon,$inactive_window_icon}#W ${separator_end}"
}
Expand All @@ -38,9 +48,15 @@ function generate_active_window_string() {
zoomed_window_icon=$(get_tmux_option "@theme_plugin_zoomed_window_icon" "")
pane_synchronized_icon=$(get_tmux_option "@theme_plugin_pane_synchronized_icon" "")

separator_start="#[bg=${PALLETE['magenta']},fg=${PALLETE['bg_highlight']}]${left_separator:?}#[none]"
separator_internal="#[bg=${PALLETE['purple']},fg=${PALLETE['magenta']}]${left_separator:?}#[none]"
separator_end="#[bg=${PALLETE[bg_highlight]},fg=${PALLETE['purple']}]${left_separator:?}#[none]"
if [ "$transparent" = "true" ]; then
separator_start="#[bg=default,fg=${PALLETE['magenta']}]${left_separator_inverse}#[bg=${PALLETE['magenta']},fg=${PALLETE['bg_highlight']}]"
separator_internal="#[bg=${PALLETE['purple']},fg=${PALLETE['magenta']}]${left_separator:?}#[none]"
separator_end="#[bg=default,fg=${PALLETE['purple']}]${left_separator:?}#[none]"
else
separator_start="#[bg=${PALLETE['magenta']},fg=${PALLETE['bg_highlight']}]${left_separator:?}#[none]"
separator_internal="#[bg=${PALLETE['purple']},fg=${PALLETE['magenta']}]${left_separator:?}#[none]"
separator_end="#[bg=${PALLETE[bg_highlight]},fg=${PALLETE['purple']}]${left_separator:?}#[none]"
fi

echo "${separator_start}#[fg=${PALLETE[white]}]#I${separator_internal}#[fg=${PALLETE[white]}] #{?window_zoomed_flag,$zoomed_window_icon,$active_window_icon}#W #{?pane_synchronized,$pane_synchronized_icon, }${separator_end}#[none]"
}

0 comments on commit 4ba288a

Please sign in to comment.