add now playing info

This commit is contained in:
Sem
2026-04-07 23:48:02 +02:00
parent 225538148d
commit 9d04b30629
4 changed files with 97 additions and 1 deletions

View File

@@ -0,0 +1,43 @@
import Quickshell.Io
import QtQuick
Item {
id: root
property string artist: ""
property string title: ""
property string artUrl: ""
property bool isPlaying: false
Process {
id: playerctlProc
// we need a separator, so use |||
command: ["playerctl", "metadata", "--format", "{{artist}}|||{{title}}|||{{mpris:artUrl}}|||{{status}}"]
stdout: StdioCollector {
onStreamFinished: {
var text = this.text.trim();
if (!text) {
root.artist = "";
root.title = "";
root.artUrl = "";
root.isPlaying = false;
return;
}
var parts = text.split("|||");
root.artist = parts[0] || "";
root.title = parts[1] || "";
root.artUrl = parts[2] || "";
root.isPlaying = (parts[3] || "").trim() === "Playing";
}
}
}
Timer {
interval: 2000
running: true
repeat: true
onTriggered: playerctlProc.running = true
}
Component.onCompleted: playerctlProc.running = true
}