mpris applet reads service directly, fix accent color gradient with pinned dock
This commit is contained in:
parent
02910957f1
commit
200a844062
6 changed files with 31 additions and 63 deletions
|
|
@ -15,7 +15,8 @@ Item {
|
|||
if (!scr)
|
||||
return 0.5;
|
||||
const gx = mapToGlobal(width / 2, 0).x - scr.x;
|
||||
return Math.max(0, Math.min(1, gx / scr.width));
|
||||
const effectiveWidth = scr.width - (S.DockState.reservedWidth ?? 0);
|
||||
return Math.max(0, Math.min(1, gx / (effectiveWidth > 0 ? effectiveWidth : scr.width)));
|
||||
}
|
||||
property color borderColor: Qt.rgba(S.Theme.base0C.r + (S.Theme.base09.r - S.Theme.base0C.r) * _posFrac, S.Theme.base0C.g + (S.Theme.base09.g - S.Theme.base0C.g) * _posFrac, S.Theme.base0C.b + (S.Theme.base09.b - S.Theme.base0C.b) * _posFrac, 1)
|
||||
property bool leftEdge: false
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue