Add nicer formatting on battery info

This commit is contained in:
2024-11-07 14:11:33 +01:00
parent 3604d6db3f
commit 16cd9b6c6e

View File

@ -18,7 +18,8 @@ date_formatted=$(date "+%a %F %H:%M")
battery_info=$(upower --show-info $(upower --enumerate |\
grep 'BAT') |\
egrep "state|percentage" |\
awk '{print $2}')
awk -v ORS=" " '{print $2}' |\
awk '{printf "%s%% (%s)", $2, $1}')
# "amixer -M" gets the mapped volume for evaluating the percentage which
# is more natural to the human ear according to "man amixer".
@ -42,4 +43,4 @@ temp=$(cat /sys/class/thermal/thermal_zone*/temp | sed 's/...$/°C/')
# Mem info
mem=$(free -m | grep Mem | awk '{printf "%d%%", ($3/$2)*100}')
echo "V: "$audio_volume" | M: "$mem" | B: "$battery_info" | T: "$temp" | N: "$ip_address" | "$date_formatted
echo "V:"$audio_volume" | M:"$mem" | B:"$battery_info") | T:"$temp" | N:"$ip_address" | "$date_formatted