diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-06-05 17:42:02 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-06-05 17:42:02 +1000 |
| commit | 6afd2a1525c1141e124190a4a51a5944f02353c3 (patch) | |
| tree | a82a19489bb4c9ed79d4001d4ac4d5a76174546e | |
| parent | dashboard: center media pane (diff) | |
| download | caelestia-shell-6afd2a1525c1141e124190a4a51a5944f02353c3.tar.gz caelestia-shell-6afd2a1525c1141e124190a4a51a5944f02353c3.tar.bz2 caelestia-shell-6afd2a1525c1141e124190a4a51a5944f02353c3.zip | |
internal: move cava to service
| -rw-r--r-- | modules/dashboard/Media.qml | 19 | ||||
| -rw-r--r-- | services/Cava.qml | 19 |
2 files changed, 26 insertions, 12 deletions
diff --git a/modules/dashboard/Media.qml b/modules/dashboard/Media.qml index 15f0232..27b7c44 100644 --- a/modules/dashboard/Media.qml +++ b/modules/dashboard/Media.qml @@ -21,8 +21,6 @@ Item { return active?.length ? active.position / active.length : 0; } - property list<int> cava: [] - function lengthStr(length: int): string { if (length < 0) return "-1:-1"; @@ -48,15 +46,12 @@ Item { onTriggered: Players.active?.positionChanged() } - Process { - running: true - command: ["sh", "-c", `printf '[general]\nframerate=60\nbars=${DashboardConfig.visualiserBars}\n[output]\nchannels=mono\nmethod=raw\nraw_target=/dev/stdout\ndata_format=ascii\nascii_max_range=100' | cava -p /dev/stdin`] - stdout: SplitParser { - onRead: data => { - root.cava = data.slice(0, -1).split(";").map(v => parseInt(v, 10)); - if (root.shouldUpdate) - visualiser.requestPaint(); - } + Connections { + target: Cava + + function onValuesChanged(): void { + if (root.shouldUpdate) + visualiser.requestPaint(); } } @@ -78,7 +73,7 @@ Item { const ctx = getContext("2d"); ctx.reset(); - const values = root.cava; + const values = Cava.values; const len = values.length; ctx.strokeStyle = colour; diff --git a/services/Cava.qml b/services/Cava.qml new file mode 100644 index 0000000..eaa6e20 --- /dev/null +++ b/services/Cava.qml @@ -0,0 +1,19 @@ +pragma Singleton + +import "root:/config" +import Quickshell +import Quickshell.Io + +Singleton { + id: root + + property list<int> values + + Process { + running: true + command: ["sh", "-c", `printf '[general]\nframerate=60\nbars=${DashboardConfig.visualiserBars}\n[output]\nchannels=mono\nmethod=raw\nraw_target=/dev/stdout\ndata_format=ascii\nascii_max_range=100' | cava -p /dev/stdin`] + stdout: SplitParser { + onRead: data => root.values = data.slice(0, -1).split(";").map(v => parseInt(v, 10)) + } + } +} |