Skip to content

Commit

Permalink
Mpris2 widget - add player name field
Browse files Browse the repository at this point in the history
Adds the ability to display the player name by using the
`"{qtile:player}"` field in the format string.
  • Loading branch information
elParaguayo committed Oct 21, 2024
1 parent b77241f commit f517041
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libqtile/widget/mpris2widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ class Mpris2(base._TextBox):
"{xesam:title} - {xesam:album} - {xesam:artist}",
"Format string for displaying metadata. "
"See http://www.freedesktop.org/wiki/Specifications/mpris-spec/metadata/#index5h3 "
"for available values",
"for available values. The special filed '{qtile:player}' can be used to display the "
"player name.",
),
("separator", ", ", "Separator for metadata fields that are a list."),
(
Expand Down Expand Up @@ -379,6 +380,8 @@ def get_track_info(self, metadata: dict[str, Variant]) -> str:
self.metadata[new_key] = val
elif isinstance(val, list):
self.metadata[new_key] = self.separator.join(y for y in val if isinstance(y, str))
if self.player is not None:
self.metadata["qtile:player"] = self.player

return self._formatter.format(self.format, **self.metadata).replace("\n", "")

Expand Down

0 comments on commit f517041

Please sign in to comment.