From 247da26c7be6de0c575a71bb0d8ef09d12bd7fa6 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Wed, 11 Mar 2026 23:33:45 +0100 Subject: [PATCH] make battery icons adapt to battery percentage --- dots/.config/quickshell/ii/modules/common/Icons.qml | 11 +++++++++++ .../modules/hefty/topLayer/bar/widgets/HResources.qml | 2 +- .../quickshell/ii/modules/ii/bar/BatteryPopup.qml | 2 +- .../quickshell/ii/modules/ii/lock/LockSurface.qml | 2 +- .../ii/modules/ii/overlay/OverlayTaskbar.qml | 2 +- .../ii/modules/ii/verticalBar/BatteryIndicator.qml | 2 +- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/dots/.config/quickshell/ii/modules/common/Icons.qml b/dots/.config/quickshell/ii/modules/common/Icons.qml index 96a745b9f..30bd3bf14 100644 --- a/dots/.config/quickshell/ii/modules/common/Icons.qml +++ b/dots/.config/quickshell/ii/modules/common/Icons.qml @@ -8,6 +8,17 @@ import qs.services Singleton { id: root + function getBatteryIcon(percentage: int): string { + if (percentage >= 93) return "battery_android_full"; + if (percentage >= 78) return "battery_android_6"; + if (percentage >= 64) return "battery_android_5"; + if (percentage >= 50) return "battery_android_4"; + if (percentage >= 35) return "battery_android_3"; + if (percentage >= 21) return "battery_android_2"; + if (percentage >= 7) return "battery_android_1"; + return "battery_android_0"; + } + function getBluetoothDeviceMaterialSymbol(systemIconName: string): string { if (systemIconName.includes("headset") || systemIconName.includes("headphones")) return "headphones"; diff --git a/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/widgets/HResources.qml b/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/widgets/HResources.qml index 29d6d978e..6d4f0e8a3 100644 --- a/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/widgets/HResources.qml +++ b/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/widgets/HResources.qml @@ -185,7 +185,7 @@ HBarWidgetWithPopout { return "energy_savings_leaf"; if (PowerProfiles.profile == PowerProfile.Performance) return "local_fire_department"; - return "battery_android_full"; + return C.Icons.getBatteryIcon(battCircProg.value * 100); } } } diff --git a/dots/.config/quickshell/ii/modules/ii/bar/BatteryPopup.qml b/dots/.config/quickshell/ii/modules/ii/bar/BatteryPopup.qml index 84b25cbc1..0ce472791 100644 --- a/dots/.config/quickshell/ii/modules/ii/bar/BatteryPopup.qml +++ b/dots/.config/quickshell/ii/modules/ii/bar/BatteryPopup.qml @@ -15,7 +15,7 @@ StyledPopup { // Header StyledPopupHeaderRow { - icon: "battery_android_full" + icon: Icons.getBatteryIcon(Battery.percentage * 100) label: Translation.tr("Battery") } diff --git a/dots/.config/quickshell/ii/modules/ii/lock/LockSurface.qml b/dots/.config/quickshell/ii/modules/ii/lock/LockSurface.qml index 82d10260a..0bee2ddf2 100644 --- a/dots/.config/quickshell/ii/modules/ii/lock/LockSurface.qml +++ b/dots/.config/quickshell/ii/modules/ii/lock/LockSurface.qml @@ -307,7 +307,7 @@ MouseArea { IconAndTextPair { visible: Battery.available - icon: Battery.isCharging ? "bolt" : "battery_android_full" + icon: Battery.isCharging ? "bolt" : Icons.getBatteryIcon(Battery.percentage * 100) text: Math.round(Battery.percentage * 100) color: (Battery.isLow && !Battery.isCharging) ? Appearance.colors.colError : Appearance.colors.colOnSurfaceVariant } diff --git a/dots/.config/quickshell/ii/modules/ii/overlay/OverlayTaskbar.qml b/dots/.config/quickshell/ii/modules/ii/overlay/OverlayTaskbar.qml index b182a2ffa..1d4019f8d 100644 --- a/dots/.config/quickshell/ii/modules/ii/overlay/OverlayTaskbar.qml +++ b/dots/.config/quickshell/ii/modules/ii/overlay/OverlayTaskbar.qml @@ -92,7 +92,7 @@ Rectangle { id: boltIcon anchors.verticalCenter: parent.verticalCenter fill: 1 - text: Battery.isCharging ? "bolt" : "battery_android_full" + text: Battery.isCharging ? "bolt" : Icons.getBatteryIcon(Battery.percentage * 100) color: batteryWidget.colText iconSize: 24 animateChange: true diff --git a/dots/.config/quickshell/ii/modules/ii/verticalBar/BatteryIndicator.qml b/dots/.config/quickshell/ii/modules/ii/verticalBar/BatteryIndicator.qml index 3f20cbd2c..0302486dd 100644 --- a/dots/.config/quickshell/ii/modules/ii/verticalBar/BatteryIndicator.qml +++ b/dots/.config/quickshell/ii/modules/ii/verticalBar/BatteryIndicator.qml @@ -44,7 +44,7 @@ MouseArea { id: boltIcon Layout.alignment: Qt.AlignHCenter fill: 1 - text: isCharging ? "bolt" : "battery_android_full" + text: isCharging ? "bolt" : Icons.getBatteryIcon(Battery.percentage * 100) iconSize: Appearance.font.pixelSize.normal animateChange: true }