From 86f56f6bdc72b48ad2a762155d6444d304be6c83 Mon Sep 17 00:00:00 2001 From: lucy Date: Mon, 19 Jan 2026 00:06:43 +0100 Subject: [PATCH] add indicator for powerprofile --- modules/bar/Battery.qml | 50 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/modules/bar/Battery.qml b/modules/bar/Battery.qml index c63ca19..776539f 100644 --- a/modules/bar/Battery.qml +++ b/modules/bar/Battery.qml @@ -1,5 +1,8 @@ import Quickshell.Services.UPower import QtQuick +import Quickshell.Widgets +import Qt5Compat.GraphicalEffects +import Quickshell import "../../reusables/" import "../../settings/" import "../../" @@ -17,8 +20,8 @@ Loader { implicitWidth: root.implicitWidth + 20 implicitHeight: Settings.config.barHeight - 10 Item { - anchors.centerIn: parent id: root + anchors.centerIn: parent property bool frame1: UPower.displayDevice.percentage <= 0.16 property bool frame2: UPower.displayDevice.percentage < 0.32 @@ -50,6 +53,17 @@ Loader { return "battery_android_frame_full"; } } + function getProfileIcon() { + if (PowerProfiles.profile.toString() == "2") { + return "power-profile-performance-symbolic"; + } + if (PowerProfiles.profile.toString() == "1") { + return "power-profile-balanced-symbolic"; + } + if (PowerProfiles.profile.toString() == "0") { + return "power-profile-power-saver-symbolic"; + } + } implicitWidth: batRow.width implicitHeight: Settings.config.barHeight @@ -66,6 +80,40 @@ Loader { id: batIcon text: root.getBatteryIcon() } + Item { + anchors.verticalCenter: parent.verticalCenter + implicitWidth: 12 + implicitHeight: 12 + + IconImage { + id: rawProfileIcon + anchors.fill: parent + source: Quickshell.iconPath(root.getProfileIcon()) + visible: false // 🤫 Shh! Hide the dark original + } + + ColorOverlay { + anchors.fill: parent + source: rawProfileIcon + color: "white" // ✨ The magic dye! + } + } + } + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: mouse => { + const modes = [PowerProfile.PowerSaver, PowerProfile.Balanced, PowerProfile.Performance]; + let current = PowerProfiles.profile; + let currentIndex = modes.indexOf(current); + let nextIndex = (currentIndex + 1) % modes.length; + let prevIndex = (currentIndex - 1) % modes.length; + if (mouse.button == Qt.LeftButton) + PowerProfiles.profile = modes[nextIndex]; + if (mouse.button == Qt.RightButton) + PowerProfiles.profile = modes[prevIndex]; + } } } }