feat(power): add power profile component

This commit is contained in:
tux
2026-08-23 17:45:45 +05:30
parent 1ded80d1c0
commit 3b01362a5a
4 changed files with 35 additions and 0 deletions

1
assets/icons/power.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M5.66953 9.91436L8.73167 5.77133C10.711 3.09327 11.7007 1.75425 12.6241 2.03721C13.5474 2.32018 13.5474 3.96249 13.5474 7.24712V7.55682C13.5474 8.74151 13.5474 9.33386 13.926 9.70541L13.946 9.72466C14.3327 10.0884 14.9492 10.0884 16.1822 10.0884C18.4011 10.0884 19.5106 10.0884 19.8855 10.7613C19.8917 10.7724 19.8977 10.7837 19.9036 10.795C20.2576 11.4784 19.6152 12.3475 18.3304 14.0857L15.2683 18.2287C13.2889 20.9067 12.2992 22.2458 11.3758 21.9628C10.4525 21.6798 10.4525 20.0375 10.4525 16.7528L10.4526 16.4433C10.4526 15.2585 10.4526 14.6662 10.074 14.2946L10.054 14.2754C9.6673 13.9117 9.05079 13.9117 7.81775 13.9117C5.59888 13.9117 4.48945 13.9117 4.1145 13.2387C4.10829 13.2276 4.10225 13.2164 4.09639 13.205C3.74244 12.5217 4.3848 11.6526 5.66953 9.91436Z" fill="#000"></path> </g></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -13,6 +13,7 @@ Singleton {
property var left: [
root.widget("LauncherButton"),
root.widget("PowerProfileWidget"),
root.widget("BatteryIndicator"),
]

View File

@@ -0,0 +1,11 @@
pragma ComponentBehavior: Bound
import qs.ui
import qs.services
BarButton {
hoverHighlight: false
pointerCursor: false
label: PowerProfile.name
iconSource: PowerProfile.icon
}

22
services/PowerProfile.qml Normal file
View File

@@ -0,0 +1,22 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Services.UPower as UPower
Singleton {
id: root
readonly property bool performanceAvailable: UPower.PowerProfiles.hasPerformanceProfile
readonly property string name: {
switch (UPower.PowerProfiles.profile) {
case UPower.PowerProfile.Performance:
return "Performance";
case UPower.PowerProfile.PowerSaver:
return "Power Saver";
default:
return "Balanced";
}
}
readonly property url icon: `${Quickshell.shellPath("assets")}/icons/power.svg`
}