Skip to content

Commit 9c7e89a

Browse files
add docs and better defaults
1 parent 44290df commit 9c7e89a

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

docs/CONFIG.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- [Plugins](#Plugins)
1010
- [attached-clients](#attached-clients---up)
1111
- [battery](#battery---up)
12+
- [compact-alt](#compact-alt---up)
1213
- [continuum](#continuum---up)
1314
- [cpu-usage](#cpu-usage---up)
1415
- [cwd](#cwd---up)
@@ -198,6 +199,44 @@ alternatively, if you have no battery and would like a nerdfont icon to indicate
198199
set -g @dracula-no-battery-label ""
199200
```
200201

202+
### compact-alt - [up](#table-of-contents)
203+
This widget allows the user to switch to an alternate list of widgets when the terminal becomes narrow.
204+
Switching only works if the widget is added to `set -g @dracula-plugins "your-plugins-here"`.
205+
206+
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.*
207+
208+
```bash
209+
set -g @dracula-narrow-plugins "compact-alt battery network weather"
210+
```
211+
212+
to determine when to switch to narrow mode, set the following variable.
213+
any value below this threshold is considered narrow.
214+
215+
```bash
216+
set -g @dracula-compact-min-width 140
217+
```
218+
219+
the compact-alt widget needs to reload your tmux config to switch from wide to narrow and back.
220+
therefore, you need to make sure to set the right path to your config file.
221+
222+
```bash
223+
set -g @dracula-config-path "$HOME/.config/tmux/tmux.conf"
224+
```
225+
226+
if you want to see your window with and whether narrow mode is active, set the following, which is false per default.
227+
228+
```bash
229+
set -g @dracula-compact-alt-verbose true
230+
```
231+
232+
this widget maintains a global variable informing about whether narrow mode is active.
233+
that variable should never be touched by the user and could potentially be used by other widgets/ plugins.
234+
235+
```bash
236+
# NEVER DO:
237+
set -g @dracula-narrow-mode some-value
238+
```
239+
201240
### continuum - [up](#table-of-contents)
202241

203242
Set the output mode. Options are:

scripts/compact_alt.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ source $current_dir/utils.sh
88
main()
99
{
1010
# get options
11-
min_width=$(get_tmux_option "@dracula-compact-min-width" "200")
11+
min_width=$(get_tmux_option "@dracula-compact-min-width" "140")
1212

1313
# get current window with
1414
local window_width
@@ -27,10 +27,14 @@ main()
2727
# if width changed, set global var and reload
2828
if [[ "$narrow" != "$narrow_mode" ]]; then
2929
tmux set -g @dracula-narrow-mode $narrow
30-
tmux source-file $(get_tmux_option "@dracula-config-path" "$HOME/.config/tmux/tmux.conf")
30+
tmux source-file "$(get_tmux_option "@dracula-config-path" "$HOME/.config/tmux/tmux.conf")"
31+
fi
32+
33+
# show widget info if verbose
34+
verbose=$(get_tmux_option "@dracula-compact-alt-verbose" false)
35+
if $verbose; then
36+
echo "$window_width - $narrow"
3137
fi
32-
# TODO: test and think about what to display
33-
echo "$window_width aa $narrow"
3438
}
3539

3640
#run main driver program

0 commit comments

Comments
 (0)