60 lines
1.5 KiB
QML
60 lines
1.5 KiB
QML
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 = "";
|
|
return;
|
|
}
|
|
var parts = text.split("|||");
|
|
root.artist = parts[0] || "";
|
|
root.title = parts[1] || "";
|
|
root.artUrl = parts[2] || "";
|
|
}
|
|
}
|
|
}
|
|
|
|
Process {
|
|
id: playerCtlPlayingProc
|
|
command: ["playerctl", "status"]
|
|
stdout: StdioCollector {
|
|
onStreamFinished: {
|
|
var status = this.text.trim();
|
|
root.isPlaying = (status === "Playing");
|
|
}
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
interval: 2000
|
|
running: true
|
|
repeat: true
|
|
onTriggered: playerctlProc.running = true
|
|
}
|
|
|
|
Timer {
|
|
interval: 1000
|
|
running: true
|
|
repeat: true
|
|
onTriggered: playerCtlPlayingProc.running = true
|
|
}
|
|
|
|
Component.onCompleted: playerctlProc.running = true
|
|
}
|