2026-03-08 13:44:57 +01:00
|
|
|
import Quickshell
|
|
|
|
|
import Quickshell.Services.Mpris
|
|
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import qs
|
|
|
|
|
import qs.settings
|
|
|
|
|
import qs.widgets
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: root
|
2026-03-11 14:14:04 +01:00
|
|
|
color: Colors.base01
|
2026-03-09 10:02:44 +01:00
|
|
|
implicitWidth: songLayout.implicitWidth + 14
|
2026-03-08 13:44:57 +01:00
|
|
|
implicitHeight: Settings.config.barHeight / 2 + 6
|
|
|
|
|
radius: Settings.config.rounding
|
|
|
|
|
property var spotify: root.getSpotify()
|
2026-03-09 10:02:44 +01:00
|
|
|
visible: getSpotify() == null ? false : true
|
2026-03-08 13:44:57 +01:00
|
|
|
|
|
|
|
|
function getSpotify() {
|
|
|
|
|
for (var i = 0; i < Mpris.players.values.length; i++) {
|
2026-03-11 14:14:04 +01:00
|
|
|
if (Mpris.players.values[i].identity == "Spotify" || Mpris.players.values[i] == "spotify") {
|
2026-03-08 13:44:57 +01:00
|
|
|
return Mpris.players.values[i];
|
2026-03-11 14:14:04 +01:00
|
|
|
} else {
|
|
|
|
|
return null;
|
2026-03-08 13:44:57 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2026-03-11 14:14:04 +01:00
|
|
|
|
2026-03-09 10:02:44 +01:00
|
|
|
RowLayout {
|
|
|
|
|
id: songLayout
|
2026-03-08 13:44:57 +01:00
|
|
|
anchors.centerIn: parent
|
2026-03-09 10:02:44 +01:00
|
|
|
CText {
|
|
|
|
|
id: playingSong
|
|
|
|
|
Layout.maximumWidth: 400
|
|
|
|
|
text: root.spotify == null ? "" : root.spotify.trackTitle + " - " + root.spotify.trackArtist
|
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
}
|
2026-03-08 13:44:57 +01:00
|
|
|
}
|
|
|
|
|
}
|