From e7a56e0e5b2aa11aecfc8bc3bb9604ca6604b138 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Mon, 7 Jun 2021 14:49:57 +0300 Subject: [PATCH] [scripts/playerctl-simple-menu] display the file path if it doesn't have metadata for title --- scripts/playerctl-simple-menu | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/playerctl-simple-menu b/scripts/playerctl-simple-menu index 17d6dd3..25e1ee4 100755 --- a/scripts/playerctl-simple-menu +++ b/scripts/playerctl-simple-menu @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# type: ignore # A simple graphical menu to control MPRIS-compatible players through Playerctl. # @@ -7,7 +8,9 @@ # TODO: Update the menu on player status changes. import math +import posixpath import sys +import urllib.parse import gi @@ -59,6 +62,14 @@ def iter_metadata_entries_for_player(player): if album: yield album.get_string() + else: + url = metadata.lookup_value("xesam:url") + if url: + url_parsed = urllib.parse.urlparse(url.get_string()) + if url_parsed.scheme == "file": + filename = posixpath.basename(urllib.parse.unquote(url_parsed.path)) + yield filename + if player.props.can_seek: position_secs = player.props.position / 1e6 duration = metadata.lookup_value("mpris:length")