From 2442f774e4fdfb7f29347ee3abda6bea7b534f1d Mon Sep 17 00:00:00 2001 From: robert stringer <62722976+pipetogrep@users.noreply.github.com> Date: Sun, 31 Aug 2025 09:24:54 +0100 Subject: [PATCH] fix: cleans the output of upower, strips the percentage and decimals, prevents arithmetic syntax error (#1236) Co-authored-by: xz --- bin/omarchy-battery-monitor | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/omarchy-battery-monitor b/bin/omarchy-battery-monitor index 05f4a440..fd16afb1 100755 --- a/bin/omarchy-battery-monitor +++ b/bin/omarchy-battery-monitor @@ -6,7 +6,13 @@ BATTERY_THRESHOLD=10 NOTIFICATION_FLAG="/run/user/$UID/omarchy_battery_notified" 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() {