From 6629046ec2e628f8bbc67bab5394f2e7e43624af Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Sat, 29 Oct 2022 13:28:27 +0100 Subject: [PATCH] Don't display battery %age on WSL system with no battery --- system-info/system-info-WSL.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system-info/system-info-WSL.sh b/system-info/system-info-WSL.sh index 8274d83..d42f3aa 100755 --- a/system-info/system-info-WSL.sh +++ b/system-info/system-info-WSL.sh @@ -31,7 +31,9 @@ while true; do raw_battery=$(powershell.exe -NoProfile \ "(Get-WmiObject win32_battery).EstimatedChargeRemaining" \ | sed 's/\r//') - battery=$(printf "%3d%%" "$raw_battery") + if [ "" != "$raw_battery" ]; then + battery=$(printf "%3d%%" "$raw_battery") + fi echo "$cpu_temp$cpu_load$battery" > $cache_file # echo -e "HTTP/1.1 200 OK\n\n$cpu_temp $cpu_load" | nc -l -k -p 8080 -q 1;