quickshell/modules/Bar/MPris.qml

56 lines
1.4 KiB
QML
Raw Normal View History

import Quickshell
import Quickshell.Services.Mpris
2026-03-20 10:34:10 +01:00
import Quickshell.Widgets
import QtQuick
2026-03-19 11:32:23 +01:00
import Qt5Compat.GraphicalEffects
import QtQuick.Layouts
import qs
import qs.settings
import qs.widgets
2026-03-20 10:34:10 +01:00
WrapperRectangle {
id: root
2026-03-20 10:34:10 +01:00
margin: Settings.config.barmargins
layer {
enabled: true
effect: DropShadow {
color: Colors.base01
radius: 4
verticalOffset: 2
horizontalOffset: 2
samples: 18
}
}
2026-03-19 11:32:23 +01:00
color: Colors.base02
2026-03-20 10:34:10 +01:00
implicitWidth: songLayout.implicitWidth + 20
implicitHeight: Settings.config.barHeight - margin * 2
radius: Settings.config.rounding
property var spotify: root.getSpotify()
visible: getSpotify() == null ? false : true
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") {
return Mpris.players.values[i];
2026-03-11 14:14:04 +01:00
} else {
return null;
}
}
return null;
}
2026-03-11 14:14:04 +01:00
2026-03-20 10:34:10 +01:00
child: Item {
RowLayout {
id: songLayout
anchors.centerIn: parent
CText {
id: playingSong
Layout.maximumWidth: 400
text: root.spotify == null ? "" : root.spotify.trackTitle + " - " + root.spotify.trackArtist
elide: Text.ElideRight
}
}
}
}