fixes waybar, adds quickshell
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
// PowerProfilesWidget.qml - ⚡/⚖/🔋 + click-to-cycle
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
import ".."
|
||||
|
||||
Pill {
|
||||
id: root
|
||||
property string profile: "balanced"
|
||||
|
||||
readonly property var profileOrder: ["performance", "balanced", "power-saver"]
|
||||
readonly property var icons: ({
|
||||
"performance": "⚡",
|
||||
"balanced": "⚖",
|
||||
"power-saver": "🔋",
|
||||
})
|
||||
|
||||
onClicked: (m) => {
|
||||
if (m.button !== Qt.LeftButton) return;
|
||||
const i = profileOrder.indexOf(root.profile);
|
||||
const next = profileOrder[(i + 1) % profileOrder.length];
|
||||
setProc.command = ["powerprofilesctl", "set", next];
|
||||
setProc.running = true;
|
||||
root.profile = next; // optimistic update
|
||||
}
|
||||
|
||||
Text {
|
||||
text: (root.icons[root.profile] ?? "⚡")
|
||||
font.family: Theme.fontSans
|
||||
font.pixelSize: Theme.fontSize
|
||||
color: Theme.foreground
|
||||
}
|
||||
|
||||
// Read current profile periodically
|
||||
Process {
|
||||
id: readProc
|
||||
running: false
|
||||
command: ["powerprofilesctl", "get"]
|
||||
stdout: SplitParser {
|
||||
onRead: (line) => root.profile = line.trim()
|
||||
}
|
||||
onExited: readProc.running = false
|
||||
}
|
||||
|
||||
// Setter - command is rewritten on each click
|
||||
Process {
|
||||
id: setProc
|
||||
running: false
|
||||
command: ["true"]
|
||||
onExited: setProc.running = false
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 2000
|
||||
running: true
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: readProc.running = true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user