Files
dotfiles/dot_config/quickshell/shared/Gamemode.qml
T
mpuchstein 7c798c005c quickshell: run a single shared gamemode monitor
GamemodePill is instantiated per screen Variant, so it spawned one
long-lived gdbus monitor per monitor (3 on desktop). Move the watcher into
a shared Gamemode singleton so only one runs regardless of screen count.
2026-06-01 14:15:07 +02:00

38 lines
1.0 KiB
QML

pragma Singleton
import Quickshell
import Quickshell.Io
import QtQuick
// Single GameMode watcher shared by every bar instance, so only one long-lived
// `gdbus monitor` runs regardless of how many screens exist. Event-driven:
// re-checks status only when GameMode emits a register/unregister signal.
Singleton {
id: root
property bool active: false
Process {
id: gameProc
command: ["gamemoded", "--status"]
stdout: StdioCollector {
onStreamFinished: root.active = this.text.indexOf("is active") >= 0
}
}
function poll() { gameProc.running = false; gameProc.running = true; }
Process {
id: monitor
running: true
command: ["gdbus", "monitor", "-e",
"-d", "com.feralinteractive.GameMode",
"-o", "/com/feralinteractive/GameMode"]
stdout: SplitParser {
onRead: line => { if (line.indexOf("Registered") >= 0) root.poll() }
}
}
Component.onCompleted: poll()
}