quickshell: source badge from xesam:url, vinyl fallback label

This commit is contained in:
rope 2026-07-30 15:47:08 +01:00
parent 8dbdb42841
commit 02ebdc36ce

View file

@ -4094,13 +4094,50 @@ in
radius: width / 2 radius: width / 2
color: Theme.base02 color: Theme.base02
SIcon { // Art-less fallback: an actual record
anchors.centerIn: parent // rather than a flat placeholder, so
// a source with no MediaSession
// artwork (Jellyfin's web player, a
// plain <video> tag) still reads as
// deliberate. Grooves only turn
// visibly because they're eccentric
// to the disc concentric rings
// would look static while spinning.
Item {
id: blankLabel
anchors.fill: parent
visible: albumArt.status !== Image.Ready visible: albumArt.status !== Image.Ready
text: "music"
color: Theme.base04 Repeater {
font.pixelSize: 30 model: 3
Rectangle {
required property int index
anchors.centerIn: parent
anchors.horizontalCenterOffset: 1
width: vinyl.discSize - 10 - index * 14
height: width
radius: width / 2
color: "transparent"
border.width: 1
border.color: Theme.base03
opacity: 0.5
}
}
Rectangle {
anchors.centerIn: parent
width: 34; height: 34
radius: 17
color: Theme.base0C
opacity: 0.25
}
SIcon {
anchors.centerIn: parent
text: sourceBadge.glyph !== "" ? sourceBadge.glyph : "music"
color: Theme.base05
font.pixelSize: 18
}
} }
Image { Image {
id: albumArt id: albumArt
anchors.fill: parent anchors.fill: parent
@ -4132,16 +4169,24 @@ in
border.color: Theme.base03 border.color: Theme.base03
} }
// Source badge. MPRIS identity is the // Source badge. MPRIS identity only ever
// browser, not the site, so YouTube is // names the browser, so the site comes
// inferred from the art host instead. // from xesam:url in the raw metadata
// the one field that actually says where
// the audio is from.
Rectangle { Rectangle {
id: sourceBadge id: sourceBadge
readonly property string glyph: { readonly property string glyph: {
let md = mediaCard.modelData.metadata || ({});
let u = (md["xesam:url"] || "").toLowerCase();
let ident = (mediaCard.modelData.identity || "").toLowerCase(); let ident = (mediaCard.modelData.identity || "").toLowerCase();
let art = (mediaCard.modelData.trackArtUrl || "").toLowerCase(); if (u.indexOf("youtube.com") >= 0 || u.indexOf("youtu.be") >= 0) return "youtube";
if (art.indexOf("ytimg") >= 0 || ident.indexOf("youtube") >= 0) return "youtube"; if (u.indexOf("twitch.tv") >= 0) return "twitch";
if (ident.indexOf("mpv") >= 0 || ident.indexOf("vlc") >= 0) return "video"; // Jellyfin: our own server, no
// public hostname to match on.
if (u.indexOf(":8096") >= 0 || u.indexOf("jellyfin") >= 0) return "clapperboard";
if (ident.indexOf("mpv") >= 0 || ident.indexOf("vlc") >= 0) return "film";
if (u.indexOf("file://") === 0) return "music";
return ""; return "";
} }
visible: sourceBadge.glyph !== "" visible: sourceBadge.glyph !== ""