From ad895dfd4fba7ac2eff0f60ab166b22581f0fa6d Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Fri, 26 Jun 2026 15:55:02 -0400 Subject: [PATCH] Fix battery auto-detect on Linux --- tcshrc.system.Linux | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tcshrc.system.Linux b/tcshrc.system.Linux index 083b7ff..bcbbd1c 100644 --- a/tcshrc.system.Linux +++ b/tcshrc.system.Linux @@ -3,10 +3,12 @@ _debug "Sourcing tcshrc.system.Linux..." unsetenv CSHENV_BATTERY_DEVICE unsetenv CSHENV_SHOW_BATTERY_LEVEL -set battery_locations=( `ls /sys/class/power_supply/ | grep 'BAT'` ) +set battery_locations=( `ls /sys/class/power_supply/ | grep 'BAT[[:digit:]]+$' | xargs` ) -if ( $#battery_locations > 0 ) then - foreach location ( /sys/class/power_supply/BAT* ) +_debug "Locations: ${battery_locations}" + +if( ${#battery_locations} > 0 ) then + foreach location ${battery_locations} setenv CSHENV_BATTERY_DEVICE ${location}/capacity setenv CSHENV_SHOW_BATTERY_LEVEL end