Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpris: use new helper: get_replacements_list introduced with (#2242) #2284

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -280,6 +281,10 @@ def metadata(self, metadata=None):

self._metadata["nowplaying"] = metadata.get("vlc:nowplaying", None)

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

if not self._metadata.get("title"):
self._metadata["title"] = "No Track"

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
Loading