From 227d32544f091f7a2cec7fd84777848da8762080 Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Sat, 16 May 2026 00:27:18 -0400 Subject: [PATCH] Fix battery indicator scale on omarchy-shell bar Quickshell's UPowerDevice.percentage is a 0.0-1.0 real (energy / energyCapacity), not 0-100. The bar was treating it as 0-100, so a 99% charge picked the lowest icon, the tooltip read "1%", and the low-battery active state was always true. --- default/quickshell/omarchy-shell/plugins/bar/Bar.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/default/quickshell/omarchy-shell/plugins/bar/Bar.qml b/default/quickshell/omarchy-shell/plugins/bar/Bar.qml index 50617b33..867fd112 100644 --- a/default/quickshell/omarchy-shell/plugins/bar/Bar.qml +++ b/default/quickshell/omarchy-shell/plugins/bar/Bar.qml @@ -564,7 +564,7 @@ Item { var chargingIcons = ["󰢜", "󰂆", "󰂇", "󰂈", "󰢝", "󰂉", "󰢞", "󰂊", "󰂋", "󰂅"] var defaultIcons = ["󰁺", "󰁻", "󰁼", "󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󰁹"] - var index = Math.max(0, Math.min(9, Math.floor(device.percentage / 10))) + var index = Math.max(0, Math.min(9, Math.floor(device.percentage * 10))) if (device.state === UPowerDeviceState.FullyCharged) return "󰂅" if (!UPower.onBattery && device.state !== UPowerDeviceState.Charging) return "" @@ -666,7 +666,7 @@ Item { if (!device || !device.isPresent) return "" var direction = UPower.onBattery ? "↓" : "↑" - return Math.round(device.changeRate) + "W" + direction + " " + Math.round(device.percentage) + "%" + return Math.round(device.changeRate) + "W" + direction + " " + Math.round(device.percentage * 100) + "%" } function trayIconSource(icon) { @@ -1952,7 +1952,7 @@ Item { text: root.batteryIcon() horizontalMargin: 8.5 visible: device !== null && device.isPresent && device.percentage > 0 - active: device !== null && device.percentage <= 20 && UPower.onBattery + active: device !== null && device.percentage <= 0.2 && UPower.onBattery tooltipText: root.batteryTooltip() onPressed: function(button) { if (button === Qt.RightButton) root.run("omarchy-notification-send \"$(omarchy-battery-status)\"")