Add battery %age reporting in system-info-WSL.sh

This commit is contained in:
Kenneth Benzie 2022-10-03 22:26:18 +01:00
parent 9a65f59273
commit 2bb99ee369

View File

@ -28,7 +28,12 @@ while true; do
jq '.sysstat.hosts[0].statistics[0]["cpu-load"][1:]|.[].idle' | \ jq '.sysstat.hosts[0].statistics[0]["cpu-load"][1:]|.[].idle' | \
awk '$idle ~ /[-.0-9]*/ { printf "%s", substr("█▇▆▅▄▃▂▁ ", int($idle / 11), 1) }'`" awk '$idle ~ /[-.0-9]*/ { printf "%s", substr("█▇▆▅▄▃▂▁ ", int($idle / 11), 1) }'`"
echo "$cpu_temp$cpu_load" > $cache_file raw_battery=$(powershell.exe -NoProfile \
"(Get-WmiObject win32_battery).EstimatedChargeRemaining" \
| sed 's/\r//')
battery=$(printf "%3d%%" "$raw_battery")
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; # echo -e "HTTP/1.1 200 OK\n\n$cpu_temp $cpu_load" | nc -l -k -p 8080 -q 1;
sleep 2 sleep 2
done done