diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 3f3f5bba..335d07d3 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -219,6 +219,13 @@ 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. diff --git a/scripts/battery.sh b/scripts/battery.sh index d96ef33f..c0524e31 100755 --- a/scripts/battery.sh +++ b/scripts/battery.sh @@ -172,6 +172,13 @@ 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