Skip to content

fix: Hide when on a desktop #354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
7 changes: 0 additions & 7 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,6 @@ alternatively, if you have no battery and would like a nerdfont icon to indicate
set -g @dracula-no-battery-label " "
```

if you only want to hide the battery widget on a desktop pc, set the following:

```bash
# default is false
set -g @dracula-battery-hide-on-desktop true
```

### compact-alt - [up](#table-of-contents)

This widget allows the user to switch to an alternate list of widgets when the terminal becomes narrow.
Expand Down
18 changes: 8 additions & 10 deletions scripts/battery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,15 @@ main()

bat_perc=$(battery_percent)

hide_on_desktop=$(get_tmux_option "@dracula-battery-hide-on-desktop" false)
# If no battery percent and the feature flag is enabled, hide the widget completely
if $hide_on_desktop && [ -z "$bat_perc" ]; then
echo ""
return
fi

if [ -z "$bat_stat" ]; then # Test if status is empty or not
echo "$bat_label $bat_perc"
elif [ -z "$bat_perc" ]; then # In case it is a desktop with no battery percent, only AC power
if [ -z "$bat_perc" ]; then # In case it is a desktop with no battery percent, only AC power
echo "$no_bat_label"
elif [ -z "$bat_stat" ]; then # Test if status is empty or not
# Only add a space when label is not empty
if [ -n "$bat_label" ]; then
echo "$bat_label $bat_perc"
else
echo "$bat_perc"
fi
else
echo "$bat_label$bat_stat $bat_perc"
fi
Expand Down