From 535d2605f3c873d49e2caa4b5398d343126a32fb Mon Sep 17 00:00:00 2001 From: lfreixial Date: Fri, 18 Jul 2025 17:00:25 +0100 Subject: [PATCH 1/9] hide battery section for desktop pcs --- scripts/battery.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/battery.sh b/scripts/battery.sh index d96ef33f..21312c0f 100755 --- a/scripts/battery.sh +++ b/scripts/battery.sh @@ -5,6 +5,8 @@ export LC_ALL=en_US.UTF-8 current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $current_dir/utils.sh +hide_status_on_desktop="$(get_tmux_option "@dracula-battery-hide-status-on-desktop" "false")" + linux_acpi() { arg=$1 BAT=$(ls -d /sys/class/power_supply/*) @@ -172,10 +174,14 @@ main() bat_perc=$(battery_percent) - if [ -z "$bat_stat" ]; then # Test if status is empty or not + # If no battery percent, don't show anything + if [ -z "$bat_perc" ] && [ "$hide_status_on_desktop" = "true" ]; then + echo "" + return + fi + + if [ -z "$bat_stat" ]; then echo "$bat_label $bat_perc" - elif [ -z "$bat_perc" ]; then # In case it is a desktop with no battery percent, only AC power - echo "$no_bat_label" else echo "$bat_label$bat_stat $bat_perc" fi From cf89b15a1e5e2b2eeae6e83e65c8a872d5e2527f Mon Sep 17 00:00:00 2001 From: lfreixial Date: Fri, 18 Jul 2025 22:06:46 +0100 Subject: [PATCH 2/9] update docs --- docs/CONFIG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 3f3f5bba..fd6f8dd5 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -219,6 +219,12 @@ 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 +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. From 4c882e685f098f34b2d616192e972fd0a1fd960d Mon Sep 17 00:00:00 2001 From: lfreixial Date: Fri, 18 Jul 2025 22:13:16 +0100 Subject: [PATCH 3/9] update config word --- scripts/battery.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/battery.sh b/scripts/battery.sh index 21312c0f..b4049637 100755 --- a/scripts/battery.sh +++ b/scripts/battery.sh @@ -5,7 +5,6 @@ export LC_ALL=en_US.UTF-8 current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $current_dir/utils.sh -hide_status_on_desktop="$(get_tmux_option "@dracula-battery-hide-status-on-desktop" "false")" linux_acpi() { arg=$1 @@ -174,8 +173,9 @@ main() bat_perc=$(battery_percent) + hide_on_desktop="$(get_tmux_option "@dracula-battery-hide-on-desktop" "false")" # If no battery percent, don't show anything - if [ -z "$bat_perc" ] && [ "$hide_status_on_desktop" = "true" ]; then + if [ -z "$bat_perc" ] && [ "$hide_on_desktop" = "true" ]; then echo "" return fi From 592dd9c318414adcdcb2a3cdaf704ed60f705148 Mon Sep 17 00:00:00 2001 From: lfreixial Date: Fri, 18 Jul 2025 22:13:54 +0100 Subject: [PATCH 4/9] remove new line --- scripts/battery.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/battery.sh b/scripts/battery.sh index b4049637..370b0682 100755 --- a/scripts/battery.sh +++ b/scripts/battery.sh @@ -5,7 +5,6 @@ export LC_ALL=en_US.UTF-8 current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $current_dir/utils.sh - linux_acpi() { arg=$1 BAT=$(ls -d /sys/class/power_supply/*) From ae54ac235ae71d183eafd0535ed8dad764804185 Mon Sep 17 00:00:00 2001 From: lfreixial Date: Fri, 18 Jul 2025 22:16:16 +0100 Subject: [PATCH 5/9] readd comment --- scripts/battery.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/battery.sh b/scripts/battery.sh index 370b0682..5a1526be 100755 --- a/scripts/battery.sh +++ b/scripts/battery.sh @@ -179,7 +179,7 @@ main() return fi - if [ -z "$bat_stat" ]; then + if [ -z "$bat_stat" ]; then # Test if status is empty or not echo "$bat_label $bat_perc" else echo "$bat_label$bat_stat $bat_perc" From 9238769bea2d1d2dad57686da7b93e096f741b80 Mon Sep 17 00:00:00 2001 From: lfreixial Date: Fri, 18 Jul 2025 22:19:32 +0100 Subject: [PATCH 6/9] add removed code --- scripts/battery.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/battery.sh b/scripts/battery.sh index 5a1526be..7bef3b90 100755 --- a/scripts/battery.sh +++ b/scripts/battery.sh @@ -181,6 +181,8 @@ main() 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 percentage, only AC power + echo "$no_bat_label" else echo "$bat_label$bat_stat $bat_perc" fi From 23b86f0a5fa3dbbd55a6dcf09e833a1af2b5e22f Mon Sep 17 00:00:00 2001 From: lfreixial Date: Fri, 18 Jul 2025 22:20:04 +0100 Subject: [PATCH 7/9] fix comment --- scripts/battery.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/battery.sh b/scripts/battery.sh index 7bef3b90..006a5470 100755 --- a/scripts/battery.sh +++ b/scripts/battery.sh @@ -181,7 +181,7 @@ main() 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 percentage, only AC power + elif [ -z "$bat_perc" ]; then # In case it is a desktop with no battery percent, only AC power echo "$no_bat_label" else echo "$bat_label$bat_stat $bat_perc" From 909b54d221df54dda028eee7fe79352448ff466b Mon Sep 17 00:00:00 2001 From: lfreixial Date: Fri, 18 Jul 2025 22:32:29 +0100 Subject: [PATCH 8/9] add default to CONFIG.md --- docs/CONFIG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/CONFIG.md b/docs/CONFIG.md index fd6f8dd5..335d07d3 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -222,6 +222,7 @@ 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 ``` From 9af78aec6fa82982b956766d0047c148178e6182 Mon Sep 17 00:00:00 2001 From: lfreixial Date: Fri, 18 Jul 2025 22:47:07 +0100 Subject: [PATCH 9/9] address coderabbit comment --- scripts/battery.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/battery.sh b/scripts/battery.sh index 006a5470..c0524e31 100755 --- a/scripts/battery.sh +++ b/scripts/battery.sh @@ -172,9 +172,9 @@ main() bat_perc=$(battery_percent) - hide_on_desktop="$(get_tmux_option "@dracula-battery-hide-on-desktop" "false")" - # If no battery percent, don't show anything - if [ -z "$bat_perc" ] && [ "$hide_on_desktop" = "true" ]; then + 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