Krolyxon
Commit 071f97f

Branches

Refs →

aurora.configquickshellauroraGpu.qml

46 lines · 1.2 KB · QML

1pragma Singleton
2import QtQuick
3import Quickshell
4import Quickshell.Io
5
6// Mirrors your gpu_mode.sh (envycontrol -q) and can switch modes via pkexec.
7Singleton {
8 id: root
9 property string mode: "" // "" = envycontrol not available
10 property string pending: "" // mode queued, applies after reboot
11 property string message: ""
12 property bool busy: false
13 property string target: ""
14
15 function refresh() { query.running = true }
16 function set(m) {
17 if (busy) return
18 busy = true
19 message = ""
20 target = m
21 sw.command = ["pkexec", "envycontrol", "-s", m]
22 sw.running = true
23 }
24
25 Process {
26 id: query
27 command: ["envycontrol", "-q"]
28 running: true
29 stdout: StdioCollector {
30 onStreamFinished: {
31 var w = text.trim().split(/\s+/)
32 root.mode = w.length && w[0] !== "" ? w[w.length - 1] : ""
33 }
34 }
35 }
36 Process {
37 id: sw
38 stderr: StdioCollector { id: swErr }
39 onExited: (code, status) => {
40 root.busy = false
41 if (code === 0) root.pending = root.target
42 else root.message = "switch failed or cancelled"
43 root.refresh()
44 }
45 }
46}