From 798f6a618c1217e0e54e2d23acdd567069884c1e Mon Sep 17 00:00:00 2001 From: lucy Date: Sat, 16 May 2026 22:41:31 +0200 Subject: [PATCH] change mpris to only show spotify --- modules/bar/Mpris.qml | 45 +++++++++++++++---------------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/modules/bar/Mpris.qml b/modules/bar/Mpris.qml index 5e9a9ef..d404948 100644 --- a/modules/bar/Mpris.qml +++ b/modules/bar/Mpris.qml @@ -8,41 +8,26 @@ import qs.settings WrapperRectangle { id: root - property MprisPlayer spotify: findSpotify() - visible: spotify != null + property MprisPlayer spotify: { + for (const player of Mpris.players.values) { + if (player.identity === "Spotify") + return player; + } + return null; + } + visible: spotify !== null && spotify.playbackState === MprisPlaybackState.Playing leftMargin: 8 rightMargin: 8 color: Colors.base01 radius: Config.rounding - function findSpotify() { - for (let i = 0; i < Mpris.players.values.length; i++) { - let current = Mpris.players.values[i]; - if (current.identity == 'spotify' || 'Spotify') { - return current; - } else { - return null; - } + child: RowLayout { + MaterialIcon { + text: "music_note_2" } - return null; - } - child: WrapperMouseArea { - id: clickHandler - acceptedButtons: Qt.LeftButton | Qt.RightButton - cursorShape: Qt.PointingHandCursor - onClicked: mouse => { - if (mouse.button == Qt.RightButton) { - root.spotify.togglePlaying(); - } - } - child: RowLayout { - MaterialIcon { - text: "music_note_2" - } - StyledText { - Layout.maximumWidth: 400 - text: root.spotify?.trackTitle + " - " + root.spotify?.trackArtists - elide: Text.ElideRight - } + StyledText { + Layout.maximumWidth: 400 + text: root.spotify?.trackTitle + " - " + root.spotify?.trackArtists + elide: Text.ElideRight } } }