Files
Bjarne Øverli 568a734862 contrib/quickshell: add now-playing widget for Omarchy
A notification-sized Quickshell card centered along the bottom of
each screen, driven by cliamp's MPRIS service for transport and
position and by cliamp visstream for the live spectrum.

Renders a Winamp 2-style segmented spectrum analyzer with falling
peak caps and pristine Canvas2D transport icons. Theme is read
directly from the active Omarchy theme via FileView watching
~/.config/omarchy/current/theme/colors.toml so theme swaps apply
live. Sharp 90-degree corners throughout. Press Esc or Q to exit
the widget (click first to grant keyboard focus).
2026-05-14 19:13:13 +02:00

49 lines
1.3 KiB
QML

// Long-lived `cliamp visstream` Process that parses one NDJSON frame per
// line and exposes the latest bands + visualizer mode as reactive properties.
//
// Uses imperative running control (not binding) so the respawn timer can
// flip the process back on after cliamp restarts.
import Quickshell.Io
import QtQuick
Item {
id: root
property int fps: 30
property bool enabled: true
property var bands: []
property string mode: ""
function _parseLine(line) {
if (!line) return;
try {
const resp = JSON.parse(line);
if (!resp || !resp.ok) return;
if (resp.bands) root.bands = resp.bands;
if (resp.visualizer) root.mode = resp.visualizer;
} catch (e) { /* ignore parse errors */ }
}
Process {
id: proc
command: ["cliamp", "visstream", "--fps", String(root.fps)]
running: false
stdout: SplitParser {
splitMarker: "\n"
onRead: (line) => root._parseLine(line)
}
}
Component.onCompleted: if (root.enabled) proc.running = true
onEnabledChanged: proc.running = root.enabled
// Respawn loop: if cliamp wasn't up yet (or restarted), keep retrying.
Timer {
interval: 2000
running: root.enabled && !proc.running
repeat: true
onTriggered: proc.running = true
}
}