From 2acc2ebfea41255d2cbe6e1204025235dfb166a9 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 10 Mar 2026 22:00:56 +0100 Subject: [PATCH] Fix time to full/empty when there are only minutes left --- bin/omarchy-battery-remaining-time | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/bin/omarchy-battery-remaining-time b/bin/omarchy-battery-remaining-time index 9c2c7019..906d2ab8 100755 --- a/bin/omarchy-battery-remaining-time +++ b/bin/omarchy-battery-remaining-time @@ -5,12 +5,21 @@ battery_info=$(upower -i $(upower -e | grep BAT)) echo "$battery_info" | awk '/time to (empty|full)/ { - hours = int($4) - minutes = int(($4 - hours) * 60) - if (minutes > 0) { - printf "%dh %dm", hours, minutes + value = $4 + unit = $5 + if (unit == "minutes") { + hours = int(value / 60) + minutes = int(value % 60) } else { + hours = int(value) + minutes = int((value - hours) * 60) + } + if (hours > 0 && minutes > 0) { + printf "%dh %dm", hours, minutes + } else if (hours > 0) { printf "%dh", hours + } else { + printf "%dm", minutes } exit }'