internal: move cava to service
This commit is contained in:
parent
e9c4bd0bb8
commit
6afd2a1525
2 changed files with 26 additions and 12 deletions
|
|
@ -21,8 +21,6 @@ Item {
|
||||||
return active?.length ? active.position / active.length : 0;
|
return active?.length ? active.position / active.length : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
property list<int> cava: []
|
|
||||||
|
|
||||||
function lengthStr(length: int): string {
|
function lengthStr(length: int): string {
|
||||||
if (length < 0)
|
if (length < 0)
|
||||||
return "-1:-1";
|
return "-1:-1";
|
||||||
|
|
@ -48,15 +46,12 @@ Item {
|
||||||
onTriggered: Players.active?.positionChanged()
|
onTriggered: Players.active?.positionChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
Process {
|
Connections {
|
||||||
running: true
|
target: Cava
|
||||||
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 {
|
function onValuesChanged(): void {
|
||||||
onRead: data => {
|
if (root.shouldUpdate)
|
||||||
root.cava = data.slice(0, -1).split(";").map(v => parseInt(v, 10));
|
visualiser.requestPaint();
|
||||||
if (root.shouldUpdate)
|
|
||||||
visualiser.requestPaint();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,7 +73,7 @@ Item {
|
||||||
const ctx = getContext("2d");
|
const ctx = getContext("2d");
|
||||||
ctx.reset();
|
ctx.reset();
|
||||||
|
|
||||||
const values = root.cava;
|
const values = Cava.values;
|
||||||
const len = values.length;
|
const len = values.length;
|
||||||
|
|
||||||
ctx.strokeStyle = colour;
|
ctx.strokeStyle = colour;
|
||||||
|
|
|
||||||
19
services/Cava.qml
Normal file
19
services/Cava.qml
Normal file
|
|
@ -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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue