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 "\uDB80\uDC84"; const icons = ["\uDB80\uDC8E", "\uDB80\uDC7A", "\uDB80\uDC7B", "\uDB80\uDC7C", "\uDB80\uDC7D", "\uDB80\uDC7E", "\uDB80\uDC7F", "\uDB80\uDC80", "\uDB80\uDC81", "\uDB80\uDC82", "\uDB85\uDFE2"]; 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 } }