Krolyxon
Commit 7a221ea

Branches

Refs →

aurora7a221ea

aurora: replay mpd's last track on empty queue, no wheel on sliders

Author
krolyxon
Date
2026-10-28 22:15 +0530
Parent
8f5bb7c
Commit
7a221ea4db8688a1b74941f0da5d9009d64d809b

+20 −8

4 files changed

  1. M .config/quickshell/aurora/BarSlider.qml +2 −5
  2. M .config/quickshell/aurora/Media.qml +15 −0
  3. M .config/quickshell/aurora/PlayControls.qml +1 −1
  4. M .config/quickshell/aurora/SliderRow.qml +2 −2
M .config/quickshell/aurora/BarSlider.qml View
@@ -1,7 +1,7 @@
11 import QtQuick
22
33 // Dotted slider: a row of LED dots, the lit part white up to a larger head dot, the rest unlit.
4−// Click/drag sets, the wheel steps. muted = the lit dots go grey.
4+// Click/drag sets, the wheel scrolls the page past it. muted = the lit dots go grey.
55 Item {
66 id: s
77 property real value: 0
@@ -42,9 +42,6 @@ Item {
4242 }
4343 onPressed: m => setFromX(m.x)
4444 onPositionChanged: m => { if (pressed) setFromX(m.x) }
45− onWheel: w => {
46− var d = (w.angleDelta.y > 0 ? 1 : -1) * s.step * (s.to - s.from)
47− s.moved(Math.max(s.from, Math.min(s.to, s.value + d)))
48− }
45+ // no onWheel: a MouseArea without one passes the wheel on, so scrolling the page never moves a slider
4946 }
5047 }
M .config/quickshell/aurora/Media.qml View
@@ -20,6 +20,21 @@ Singleton {
2020 readonly property bool playing: player !== null && player.isPlaying
2121 readonly property bool seekable: player !== null && player.lengthSupported && player.length > 0
2222
23+ // Play/pause. mpd-mpris says CanPlay with an empty queue (it keeps the last track's metadata, trackid NoTrack),
24+ // so Play does nothing there: queue the track the card still shows again (mpc, MPRIS has no queue API).
25+ function toggle(p) {
26+ if (!p || !p.canTogglePlaying) return
27+ var md = p.metadata || {}
28+ var noTrack = String(md["mpris:trackid"] || "").endsWith("/NoTrack")
29+ if (!p.isPlaying && noTrack && p.dbusName === "org.mpris.MediaPlayer2.mpd" && p.trackTitle) {
30+ var q = ["title", p.trackTitle]
31+ if (p.trackAlbum) q.push("album", p.trackAlbum)
32+ Quickshell.execDetached(["sh", "-c", 'mpc -q findadd "$@" && mpc -q play', "sh"].concat(q))
33+ return
34+ }
35+ p.togglePlaying()
36+ }
37+
2338 function fmt(s) { // 75 -> "1:15"
2439 s = Math.max(0, Math.floor(s))
2540 var m = Math.floor(s / 60), r = s % 60
M .config/quickshell/aurora/PlayControls.qml View
@@ -31,7 +31,7 @@ Row {
3131 font.pixelSize: root.play * 0.46
3232 }
3333 HoverHandler { cursorShape: Qt.PointingHandCursor }
34− TapHandler { onTapped: if (root.player && root.player.canTogglePlaying) root.player.togglePlaying() }
34+ TapHandler { onTapped: Media.toggle(root.player) }
3535 }
3636 Icon {
3737 anchors.verticalCenter: parent.verticalCenter
M .config/quickshell/aurora/SliderRow.qml View
@@ -1,7 +1,7 @@
11 import QtQuick
22
33 // Level slider (control panel): a pill whose filled part is white with the icon in it, the rest a row of dots,
4−// the value in a chip on the right. Click/drag sets, the wheel steps, the icon end toggles mute (iconClicked).
4+// the value in a chip on the right. Click/drag sets (the wheel scrolls past it), the icon end toggles mute (iconClicked).
55 // Ported from glyph-rice (github.com/Nebelung-cloud/glyph-rice, GPL-3.0), quick/Quick.qml (Slider).
66 Item {
77 id: r
@@ -65,7 +65,7 @@ Item {
6565 function set(x) { v = Math.max(0, Math.min(1, x / width)); r.moved(v) }
6666 onPressed: e => set(e.x)
6767 onPositionChanged: e => { if (pressed) set(e.x) }
68− onWheel: w => r.moved(Math.max(0, Math.min(1, r.value + (w.angleDelta.y > 0 ? 0.02 : -0.02))))
68+ // no onWheel on purpose: the wheel scrolls the page (it kept changing volume/brightness by accident)
6969 }
7070 // the icon end: mute
7171 MouseArea {