Fix indexing into icon char buffers
This commit is contained in:
parent
4635fc169d
commit
19e9306008
@ -35,11 +35,11 @@ if upower -e | grep 'BAT' 2> /dev/null; then
|
|||||||
local percentage=$(echo $output | awk '{ print $4 }')
|
local percentage=$(echo $output | awk '{ print $4 }')
|
||||||
if [ "$charging" = "Charging," ];then
|
if [ "$charging" = "Charging," ];then
|
||||||
echo $percentage | awk '$battery ~ /.*/ {
|
echo $percentage | awk '$battery ~ /.*/ {
|
||||||
printf " %d%% %s\n", $battery, substr("", int($battery / 9), 1)
|
printf " %d%% %s\n", $battery, substr("", int($battery / 100 * 11), 1)
|
||||||
}'
|
}'
|
||||||
else
|
else
|
||||||
echo $percentage | awk '$battery ~ /.*/ {
|
echo $percentage | awk '$battery ~ /.*/ {
|
||||||
printf " %d%% %s\n", $battery, substr("", int($battery / 9), 1)
|
printf " %d%% %s\n", $battery, substr("", int($battery / 100 * 11), 1)
|
||||||
}'
|
}'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ while true; do
|
|||||||
# Parse the current CPU load on all cores/threads.
|
# Parse the current CPU load on all cores/threads.
|
||||||
cpu_load=" `mpstat -P ALL -n 1 -u 1 -o JSON | \
|
cpu_load=" `mpstat -P ALL -n 1 -u 1 -o JSON | \
|
||||||
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 / 100 * 9), 1) }'`"
|
||||||
|
|
||||||
# Parse the current CPU package temperature.
|
# Parse the current CPU package temperature.
|
||||||
cpu_temp=$(get_cpu_temp)
|
cpu_temp=$(get_cpu_temp)
|
||||||
|
|||||||
@ -32,14 +32,14 @@ while true; do
|
|||||||
|
|
||||||
cpu_load=" `mpstat -P ALL -n 1 -u 1 -o JSON | \
|
cpu_load=" `mpstat -P ALL -n 1 -u 1 -o JSON | \
|
||||||
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 / 100 * 9), 1) }'`"
|
||||||
|
|
||||||
raw_battery=$($powershell -NoProfile \
|
raw_battery=$($powershell -NoProfile \
|
||||||
"(Get-WmiObject win32_battery).EstimatedChargeRemaining" \
|
"(Get-WmiObject win32_battery).EstimatedChargeRemaining" \
|
||||||
| sed 's/\r//')
|
| sed 's/\r//')
|
||||||
if [ "" != "$raw_battery" ]; then
|
if [ "" != "$raw_battery" ]; then
|
||||||
battery="$(echo $raw_battery | awk '$battery ~ /.*/ {
|
battery="$(echo $raw_battery | awk '$battery ~ /.*/ {
|
||||||
printf " %d%% %s\n", $battery, substr("", int($battery / 9), 1)
|
printf " %d%% %s\n", $battery, substr("", int($battery / 100 * 11), 1)
|
||||||
}')"
|
}')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@ -85,9 +85,9 @@ while true; do
|
|||||||
|
|
||||||
cpu_load=$(sudo powermetrics --format text \
|
cpu_load=$(sudo powermetrics --format text \
|
||||||
--sample-rate 1200 --sample-count 1 --samplers cpu_power |
|
--sample-rate 1200 --sample-count 1 --samplers cpu_power |
|
||||||
grep --color=never -E 'CPU \d idle residency:' |
|
grep --color=never -E 'CPU \d active residency:' |
|
||||||
grep --color=never -Eo '\d+\.\d+' |
|
gawk '{print $5}' |
|
||||||
gawk '$idle ~ /[-.0-9]*/ { printf "%s", substr("█▇▆▅▄▃▂▁ ", int($idle / 10), 1) }'
|
gawk '$idle ~ /[-.0-9]*/ { printf "%s", substr(" ▁▂▃▄▅▆▇█", int($idle / 100 * 9), 1) }'
|
||||||
)
|
)
|
||||||
|
|
||||||
# Parse the current battery charge percentage.
|
# Parse the current battery charge percentage.
|
||||||
@ -97,7 +97,7 @@ while true; do
|
|||||||
grep --color=never -Eo '\d+%' | \
|
grep --color=never -Eo '\d+%' | \
|
||||||
grep --color=never -Eo '\d+')"
|
grep --color=never -Eo '\d+')"
|
||||||
battery="$(echo $raw_battery | gawk '$battery ~ /.*/ {
|
battery="$(echo $raw_battery | gawk '$battery ~ /.*/ {
|
||||||
printf " %d%% %s\n", $battery, substr("", int($battery / 9), 1)
|
printf " %d%% %s\n", $battery, substr("", int($battery / 100 * 11), 1)
|
||||||
}')"
|
}')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user