import QtQuick import Quickshell.Services.UPower import "." StatusItem { id: root required property QtObject commands readonly property var device: UPower.displayDevice readonly property bool ready: device && device.ready readonly property real rawPercentage: ready ? device.percentage : 0 // Quickshell/UPower can expose either 0..1 or 0..100 depending on backend. // Normalize here so the bar matches `upower -i` instead of lying in tests. readonly property int percent: ready ? Math.round(rawPercentage <= 1 ? rawPercentage * 100 : rawPercentage) : 0 readonly property bool hasBattery: UPower.devices.values.some(d => d.isLaptopBattery) text: hasBattery && ready ? `󰁹 ${percent}%` : "" warning: percent <= 20 && percent > 5 critical: UPower.onBattery && percent <= 5 minWidth: 52 // Keep the click behavior terminal-based for parity with the current Ironbar // diagnostics habit: visible raw UPower facts, no hidden abstraction yet. onLeftClicked: commands.openBattery() onMiddleClicked: commands.openBattery() }