How to get mpris:artUrl
from Mpris to send notifications on track change(Mpris2 Widget)
#4330
Unanswered
Tanish2002
asked this question in
Q&A
Replies: 2 comments 4 replies
-
Update: if self.track_info != self.text:
send_notification("Now Playing", self.track_info) |
Beta Was this translation helpful? Give feedback.
4 replies
-
Thanks @elParaguayo, I was able to hack together it. Leaving it here in case anyone needs it in the future: Though I still get the notification thrown twice 🤔. Would that be mpris issue? or something wrong in my implementation? from libqtile import widget
import urllib.request
import notify2
class MyMpris(widget.Mpris2):
def fetch_image(self, url):
try:
urllib.request.urlretrieve(url, "/tmp/playing.png")
return "/tmp/playing.png"
except:
return ""
def __init__(self, **config):
widget.Mpris2.__init__(self, **config)
notify2.init("qtile")
def parse_message(
self,
_interface_name,
changed_properties,
_invalidated_properties,
):
widget.Mpris2.parse_message(
self,
_interface_name,
changed_properties,
_invalidated_properties,
)
if self.track_info != self.text:
playbackstatus = getattr(
changed_properties.get("PlaybackStatus"), "value", None
)
# The player was just paused
if playbackstatus:
return
metadata = changed_properties.get("Metadata")
artwork = metadata.value.get("mpris:artUrl").value
icon = ""
if artwork:
icon = self.fetch_image(artwork)
notify2.Notification("Now Playing", self.track_info, icon).show()
# Doesn't have a parameter for icon :(
# send_notification("Now Playing", self.track_info) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The title is pretty bad. Yes.
I would like to send track change notifications with an icon(album art/video thumbnail). Like Spotify does through the Mpris2 widget.
I was able to come up with this
This works fine. It sends notification with the track on change (Also weirdly it sends the same notification twice. IDK if it's a mpris issue or not).
I would like to modify this widget to get
mpris:artUrl
Example from playerctl
I was thinking of fetching this image and sending a notification with this. Though Idk how I can modify the widget to get this artURL
Also slightly out of topic but the
send_notification
in utils should have a icon parameter as well.Beta Was this translation helpful? Give feedback.
All reactions