dashboard: optimise cava

Use refs to prevent loading at all times
This commit is contained in:
2 * r + 2 * t 2025-06-28 22:29:46 +10:00
parent 45ebf3c70e
commit c1872c2d77
3 changed files with 18 additions and 1 deletions

View file

@ -108,6 +108,10 @@ Item {
easing.bezierCurve: Appearance.anim.curves.standard
}
}
Ref {
service: Cava
}
}
StyledClippingRect {

View file

@ -8,12 +8,16 @@ Singleton {
id: root
property list<int> values
property int refCount
Process {
running: true
command: ["sh", "-c", `printf '[general]\nframerate=60\nbars=${Config.dashboard.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))
onRead: data => {
if (root.refCount)
root.values = data.slice(0, -1).split(";").map(v => parseInt(v, 10));
}
}
}
}

9
widgets/Ref.qml Normal file
View file

@ -0,0 +1,9 @@
import Quickshell
import QtQuick
QtObject {
required property Singleton service
Component.onCompleted: service.refCount++
Component.onDestruction: service.refCount--
}