pragma Singleton import QtQuick import Quickshell import "../../../../services" as GS // glassMxrph stand-in: the audio spectrum comes from glassMxrph's Cava // (Noctalia's PwAudioSpectrum is not in Quickshell 0.3.1). Singleton { id: root property var _registeredComponents: ({}) readonly property int _registeredCount: Object.keys(_registeredComponents).length readonly property var values: GS.CavaService.bars readonly property bool isIdle: !GS.CavaService.wanted property bool subscribed: false on_RegisteredCountChanged: { const want = _registeredCount > 0; if (want !== subscribed) { GS.CavaService.widgetConsumers += want ? 1 : -1; subscribed = want; } } function registerComponent(componentId) { const next = Object.assign({}, _registeredComponents); next[componentId] = true; _registeredComponents = next; } function unregisterComponent(componentId) { const next = Object.assign({}, _registeredComponents); delete next[componentId]; _registeredComponents = next; } function isRegistered(componentId) { return !!_registeredComponents[componentId]; } }