import QtQuick import Quickshell.Services.UPower import "." as M Row { id: root spacing: 4 visible: UPower.displayDevice?.isLaptopBattery ?? false readonly property var dev: UPower.displayDevice readonly property real pct: (dev?.percentage ?? 0) * 100 readonly property bool charging: dev?.state === UPowerDeviceState.Charging M.BarIcon { icon: { if (root.charging) return "󰂄"; const icons = ["󰂎", "󰁺", "󰁻", "󰁼", "󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󱟢"]; return icons[Math.min(10, Math.floor(root.pct / 10))]; } color: root.pct < 15 ? M.Theme.base08 : M.Theme.base05 font.pixelSize: M.Theme.fontSize + 2 anchors.verticalCenter: parent.verticalCenter } M.BarLabel { label: Math.round(root.pct) + "%" color: root.pct < 15 ? M.Theme.base08 : M.Theme.base05 anchors.verticalCenter: parent.verticalCenter } }