Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [Plugins](#Plugins)
- [attached-clients](#attached-clients---up)
- [battery](#battery---up)
- [compact-alt](#compact-alt---up)
- [continuum](#continuum---up)
- [cpu-usage](#cpu-usage---up)
- [cwd](#cwd---up)
Expand Down Expand Up @@ -198,6 +199,44 @@ alternatively, if you have no battery and would like a nerdfont icon to indicate
set -g @dracula-no-battery-label " "
```

### compact-alt - [up](#table-of-contents)
This widget allows the user to switch to an alternate list of widgets when the terminal becomes narrow.
Switching only works if the widget is added to `set -g @dracula-plugins "your-plugins-here"`.

to set what widgets should be shown in narrow mode, set the following variable. *make sure to include the compact-alt widget as you won't be able to switch out of narrow mode otherwise.*

```bash
set -g @dracula-narrow-plugins "compact-alt battery network weather"
```

to determine when to switch to narrow mode, set the following variable.
any value below this threshold is considered narrow.

```bash
set -g @dracula-compact-min-width 140
```

the compact-alt widget needs to reload your tmux config to switch from wide to narrow and back.
therefore, you need to make sure to set the right path to your config file.

```bash
set -g @dracula-config-path "$HOME/.config/tmux/tmux.conf"
```

if you want to see your window with and whether narrow mode is active, set the following, which is false per default.

```bash
set -g @dracula-compact-alt-verbose true
```

this widget maintains a global variable informing about whether narrow mode is active.
that variable should never be touched by the user and could potentially be used by other widgets/ plugins.

```bash
# NEVER DO:
set -g @dracula-narrow-mode some-value
```

### continuum - [up](#table-of-contents)

Set the output mode. Options are:
Expand Down
44 changes: 44 additions & 0 deletions scripts/compact_alt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# setting the locale, some users have issues with different locales, this forces the correct one
export LC_ALL=en_US.UTF-8

current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $current_dir/utils.sh

main()
{
# get options
min_width=$(get_tmux_option "@dracula-compact-min-width" "140")

# get current window with
local window_width
window_width=$(tmux display-message -p "#{window_width}")

# determine whether narrow
if [[ "$window_width" -lt "$min_width" ]]; then
narrow=true
else
narrow=false
fi

# get whether narrow previously
narrow_mode="$(tmux show-option -gqv '@dracula-narrow-mode')"

# if width changed, set global var and reload
if [[ "$narrow" != "$narrow_mode" ]]; then
tmux set -g @dracula-narrow-mode $narrow
tmux source-file "$(get_tmux_option "@dracula-config-path" "$HOME/.config/tmux/tmux.conf")"
fi

# show widget info if verbose
verbose=$(get_tmux_option "@dracula-compact-alt-verbose" false)
if $verbose; then
echo "$window_width - $narrow"
fi
# storing the refresh rate in the variable RATE, default is 5
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
sleep $RATE
}

#run main driver program
main
13 changes: 12 additions & 1 deletion scripts/dracula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ main() {
time_format=$(get_tmux_option "@dracula-time-format" "")
show_ssh_session_port=$(get_tmux_option "@dracula-show-ssh-session-port" false)
show_libreview=$(get_tmux_option "@dracula-show-libreview" false)
IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather")
show_empty_plugins=$(get_tmux_option "@dracula-show-empty-plugins" true)

narrow_mode=$(get_tmux_option "@dracula-narrow-mode" false)
if $narrow_mode; then
IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-narrow-plugins" "compact-alt battery network weather")
else
IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather")
fi

# Dracula Color Pallette
white="#f8f8f2"
gray="#44475a"
Expand Down Expand Up @@ -188,6 +194,11 @@ main() {
script="${script} not found!"
fi

elif [ $plugin = "compact-alt" ]; then
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-compact-alt-colors" "dark_gray white")
tmux set-option -g status-right-length 250
script="#($current_dir/compact_alt.sh)"

elif [ $plugin = "cwd" ]; then
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-cwd-colors" "dark_gray white")
tmux set-option -g status-right-length 250
Expand Down