Files
glassMxrph/quickshell/services/CavaService.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

61 lines
2.0 KiB
QML

pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
Singleton {
id: root
property int consumers: 0
// Desktop visualizer widgets request Cava regardless of the media card's toggle.
property int widgetConsumers: 0
property var bars: Array(24).fill(0)
property string error: ""
property int frames: 0
property bool failed: false
readonly property bool wanted: ConfigService.ready && MediaService.playing && ((ConfigService.data.media.showCava && consumers > 0) || widgetConsumers > 0)
onWantedChanged: {
if (!wanted) {
failed = false;
error = "";
bars = Array(24).fill(0);
}
}
Process {
id: process
command: ["python3", Quickshell.shellPath("helpers/cava.py"), Quickshell.shellPath("config/cava.conf")]
running: root.wanted && !root.failed
stdout: SplitParser {
onRead: data => {
const values = data.trim().split(";").filter(v => v.length).map(Number);
if (values.length === 24 && values.every(v => Number.isFinite(v) && v >= 0 && v <= 1000)) {
root.bars = values.map(v => v / 1000);
root.frames++;
}
}
}
stderr: StdioCollector {
id: errors
}
// Quickshell 0.3.1 metadata omits QProcess::ExitStatus.
// qmllint disable signal-handler-parameters
onExited: code => {
if (root.wanted) {
root.failed = true;
root.error = errors.text.trim().slice(0, 300) || "Cava stopped (" + code + ")";
}
}
}
IpcHandler {
target: "cava"
function status(): string {
return JSON.stringify({
running: process.running,
error: root.error,
bars: root.bars,
frames: root.frames,
consumers: root.consumers
});
}
}
}