mpris: cava audio visualizer overlay on album art
This commit is contained in:
parent
5886f39b08
commit
6e20ac966e
1 changed files with 44 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
import Quickshell.Services.Mpris
|
import Quickshell.Services.Mpris
|
||||||
import "." as M
|
import "." as M
|
||||||
|
|
@ -33,6 +34,24 @@ M.BarSection {
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cava visualizer — 16 bars, raw output mode
|
||||||
|
property var _cavaBars: Array(16).fill(0)
|
||||||
|
Process {
|
||||||
|
id: cavaProc
|
||||||
|
running: root.playing
|
||||||
|
command: ["sh", "-c",
|
||||||
|
"printf '[general]\\nbars=16\\nframerate=30\\n[output]\\nmethod=raw\\nraw_target=/dev/stdout\\ndata_format=ascii\\nascii_max_range=100\\n' | cava -p /dev/stdin 2>/dev/null"
|
||||||
|
]
|
||||||
|
stdout: SplitParser {
|
||||||
|
splitMarker: "\n"
|
||||||
|
onRead: line => {
|
||||||
|
const vals = line.split(";").filter(s => s).map(Number);
|
||||||
|
if (vals.length >= 16)
|
||||||
|
root._cavaBars = vals.map(v => v / 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
required property var bar
|
required property var bar
|
||||||
|
|
||||||
property bool _panelHovered: false
|
property bool _panelHovered: false
|
||||||
|
|
@ -208,6 +227,31 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Visualizer bars
|
||||||
|
Row {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
height: parent.height * 0.6
|
||||||
|
spacing: 2
|
||||||
|
visible: root.playing
|
||||||
|
opacity: 0.5
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: 16
|
||||||
|
Rectangle {
|
||||||
|
required property int index
|
||||||
|
width: (parent.width - 15 * parent.spacing) / 16
|
||||||
|
height: parent.height * (root._cavaBars[index] ?? 0)
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
color: M.Theme.base0E
|
||||||
|
radius: 1
|
||||||
|
|
||||||
|
Behavior on height { NumberAnimation { duration: 50 } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue