fix: cleans the output of upower, strips the percentage and decimals, prevents arithmetic syntax error (#1236)

Co-authored-by: xz <xz>
This commit is contained in:
robert stringer
2025-08-31 09:24:54 +01:00
committed by GitHub
parent 0d62a03ae0
commit 2442f774e4

View File

@@ -6,7 +6,13 @@ BATTERY_THRESHOLD=10
NOTIFICATION_FLAG="/run/user/$UID/omarchy_battery_notified" NOTIFICATION_FLAG="/run/user/$UID/omarchy_battery_notified"
get_battery_percentage() { get_battery_percentage() {
upower -i $(upower -e | grep 'BAT') | grep -E "percentage" | grep -o '[0-9]\+%' | sed 's/%//' upower -i "$(upower -e | grep 'BAT')" \
| awk -F: '/percentage/ {
gsub(/[%[:space:]]/, "", $2);
val=$2;
printf("%d\n", (val+0.5))
exit
}'
} }
get_battery_state() { get_battery_state() {