Files
glassMxrph/quickshell/services/SystemService.qml
T
mxandClaude Opus 5.5 99e64a7713 Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:36:17 +02:00

88 lines
2.8 KiB
QML

pragma Singleton
import QtQuick
import Quickshell
import "../core"
Singleton {
id: root
property string helper: "helpers/system.py"
property var state: ({})
property string error: ""
readonly property bool busy: job.running
// A user action is in flight. Controls lock on this, not on busy: locking
// them for every background status poll flickered them every five seconds.
readonly property bool acting: (job.running && job.request.op === "action") || queued !== null
property var queued: null
readonly property var features: {
if (!ConfigService.ready)
return [];
if (ShellState.controlCenterOpen)
return ConfigService.data.controlCenter.modules.filter(m => m.enabled && ["brightness", "nightLight", "dnd", "profiles", "power"].includes(m.id)).map(m => m.id);
if (ShellState.dashboardOpen)
return ["power"];
if (!ShellState.settingsOpen)
return [];
if (ShellState.settingsPage === "displays")
return ["brightness", "nightLight"];
if (ShellState.settingsPage === "notifications")
return ["dnd"];
if (ShellState.settingsPage === "power")
return ["power", "profiles"];
return [];
}
readonly property bool observed: features.length > 0
onFeaturesChanged: if (observed)
refresh()
onObservedChanged: if (observed)
refresh()
function refresh() {
if (ConfigService.ready && !busy)
job.start({
op: "status",
features: features,
options: ConfigService.data.system
});
}
function action(kind, value, confirmed) {
if (acting || !ConfigService.ready)
return false;
error = "";
const request = {
op: "action",
action: kind,
value: value,
confirmed: confirmed === true,
options: ConfigService.data.system
};
// A status poll is running: run the action as soon as it finishes.
if (busy) {
queued = request;
return true;
}
return job.start(request);
}
ProviderJob {
id: job
helper: root.helper
onFinished: (request, result) => {
if (result.ok) {
root.state = Object.assign({}, root.state, result.state);
if (request.op === "action")
root.error = "";
} else
root.error = result.error || "System request failed";
if (root.queued) {
const next = root.queued;
root.queued = null;
job.start(next);
}
}
}
Timer {
interval: 5000
repeat: true
running: root.observed
onTriggered: root.refresh()
}
}