Skip to content

Commit

Permalink
mpris: use new helper: get_replacements_list introduced with (ultrabu…
Browse files Browse the repository at this point in the history
  • Loading branch information
valdur55 committed Jan 21, 2025
1 parent c2d623a commit 4f561c0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion py3status/modules/mpris.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
Keep in mind that the state has a higher priority than
player_priority. So when player_priority is "[mpd, bomi]" and mpd is
paused and bomi is playing than bomi wins. (default [])
replacements: specify a list/dict of string placeholders to modify (default None)
state_pause: specify icon for pause state (default u'\u25eb')
state_play: specify icon for play state (default u'\u25b7')
state_stop: specify icon for stop state (default u'\u25a1')
Format placeholders:
{album} album name
{artist} artiste name (first one)
{artist} artist name (first one)
{length} time duration of the song
{player} show name of the player
{player_shortname} show name of the player from busname (usually command line name)
Expand Down Expand Up @@ -283,6 +284,10 @@ def metadata(self, metadata=None):
if not self._metadata.get("title"):
self._metadata["title"] = "No Track"

for x in self.parent.replacements_init:
if x in self._metadata and self._metadata[x]:
self._metadata[x] = self.parent.py3.replace(self._metadata[x], x)

@property
def state(self):
return self._state
Expand Down Expand Up @@ -379,6 +384,7 @@ class Py3status:
icon_stop = "\u25a1"
max_width = None
player_priority = []
replacements = None
state_pause = "\u25eb"
state_play = "\u25b7"
state_stop = "\u25a1"
Expand All @@ -394,6 +400,7 @@ class Meta:
}

def post_config_hook(self):
self.replacements_init = self.py3.get_replacements_list(self.format)
self._name_owner_change_match = None
self._kill = False
self._mpris_players: dict[Player] = {}
Expand Down

0 comments on commit 4f561c0

Please sign in to comment.