Fixes media control

This commit is contained in:
Michel Fedde 2025-10-22 22:47:23 +02:00
parent 6e303a2ff8
commit 12d107e3b4
3 changed files with 36 additions and 14 deletions

View file

@ -1,13 +1,28 @@
#!/bin/bash
formatReturn() {
targetArtPath="/tmp/.eww.media-art.$(tr -dc 'a-zA-Z0-9' </dev/urandom | head -c 10)"
currentArtUrl=""
currentArtPath=""
updateArtPath() {
local url="$1"
if [[ "$url" == "$currentArtUrl" ]]; then
return 0
fi
currentArtUrl="$url"
currentArtPath="/tmp/.eww.media-art.$(tr -dc 'a-zA-Z0-9' </dev/urandom | head -c 10)"
rm /tmp/.eww.media-art.*
curl $(playerctl metadata mpris:artUrl) -o "$targetArtPath" >/dev/null
curl "$url" -o "$currentArtPath" >/dev/null
}
playerctl metadata | jq -R -s -c -r --arg artPath "$targetArtPath" 'split("\n") | map(match("(\\w+) {1}([\\w:]+) {3,}(.+)") | {(.captures[1].string): .captures[2].string}) | add | .["mpris:artUrl"] = $artPath'
formatReturn() {
updateArtPath $(playerctl metadata mpris:artUrl)
playerctl metadata | jq -R -s -c -r --arg artPath "$currentArtPath" 'split("\n") | map(match("(\\w+) {1}([\\w:]+) {3,}(.+)") | {(.captures[1].string): .captures[2].string}) | add | .["mpris:artUrl"] = $artPath'
}