From adc5d3f6eefd1f5fde0a652252c53c0a5eb13b77 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Thu, 25 Jun 2026 16:47:09 -0400 Subject: [PATCH] Don't panic if no batteries are found on Linux. --- tcshrc.system.Linux | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tcshrc.system.Linux b/tcshrc.system.Linux index 3bde16c..083b7ff 100644 --- a/tcshrc.system.Linux +++ b/tcshrc.system.Linux @@ -2,10 +2,15 @@ _debug "Sourcing tcshrc.system.Linux..." unsetenv CSHENV_BATTERY_DEVICE unsetenv CSHENV_SHOW_BATTERY_LEVEL -foreach location ( /sys/class/power_supply/BAT* ) -setenv CSHENV_BATTERY_DEVICE ${location}/capacity -setenv CSHENV_SHOW_BATTERY_LEVEL -end + +set battery_locations=( `ls /sys/class/power_supply/ | grep 'BAT'` ) + +if ( $#battery_locations > 0 ) then + foreach location ( /sys/class/power_supply/BAT* ) + setenv CSHENV_BATTERY_DEVICE ${location}/capacity + setenv CSHENV_SHOW_BATTERY_LEVEL + end +endif # Set the acknowledgement bit, essentially setenv CSHENV_SYSTEM_CONFIGURED Linux