mpris applet reads service directly, fix accent color gradient with pinned dock

This commit is contained in:
Damocles 2026-04-26 13:37:34 +02:00
parent 02910957f1
commit 200a844062
6 changed files with 31 additions and 63 deletions

View file

@ -9,32 +9,20 @@ import "../applets" as C
M.BarModule {
id: root
spacing: S.Theme.moduleSpacing
opacity: S.Modules.mpris.enable && player !== null ? 1 : 0
opacity: S.Modules.mpris.enable && S.MprisService.player !== null ? 1 : 0
visible: opacity > 0
tooltip: player ? (player.trackTitle || player.identity || "Media") + (playing ? " (playing)" : " (paused)") : "Media"
tooltip: S.MprisService.player ? (S.MprisService.player.trackTitle || S.MprisService.player.identity || "Media") + (S.MprisService.playing ? " (playing)" : " (paused)") : "Media"
panelNamespace: "nova-mpris"
panelTitle: "Now Playing"
panelContentWidth: 280
panelComponent: Component {
C.MprisApplet {
width: parent.width
player: root.player
players: root._players
playing: root.playing
accentColor: root.accentColor
cachedArt: S.MprisService.cachedArt
cavaBars: root._cavaBars
playerIdx: S.MprisService.playerIdx
onPlayerSwitched: idx => {
S.MprisService.switchPlayer(idx);
root.keepPanelOpen(400);
}
}
}
readonly property var _players: S.MprisService.players
readonly property MprisPlayer player: S.MprisService.player
readonly property bool playing: S.MprisService.playing
// Cava visualizer - 16 bars, raw output mode
property var _cavaBars: Array(16).fill(0)
property bool _cavaActive: false
@ -56,7 +44,7 @@ M.BarModule {
Process {
id: cavaProc
running: root.playing && root._cavaActive
running: S.MprisService.playing && root._cavaActive
command: ["sh", "-c", "cfg=$(mktemp /tmp/nova-cava-XXXXXX.conf);" + "cat > \"$cfg\" << 'CAVAEOF'\n" + "[general]\nbars=16\nframerate=30\n[output]\nmethod=raw\nraw_target=/dev/stdout\ndata_format=ascii\nascii_max_range=100\n" + "CAVAEOF\n" + "trap 'rm -f \"$cfg\"' EXIT;" + "exec cava -p \"$cfg\""]
stdout: SplitParser {
splitMarker: "\n"
@ -71,11 +59,11 @@ M.BarModule {
required property var bar
M.BarIcon {
icon: root.playing ? "\uF04B" : (root.player?.playbackState === MprisPlaybackState.Paused ? "\uDB80\uDFE4" : "\uDB81\uDCDB")
icon: S.MprisService.playing ? "\uF04B" : (S.MprisService.player?.playbackState === MprisPlaybackState.Paused ? "\uDB80\uDFE4" : "\uDB81\uDCDB")
anchors.verticalCenter: parent.verticalCenter
}
M.BarLabel {
label: root.player?.trackTitle || root.player?.identity || ""
label: S.MprisService.player?.trackTitle || S.MprisService.player?.identity || ""
elide: Text.ElideRight
width: Math.min(implicitWidth, 200)
anchors.verticalCenter: parent.verticalCenter