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

Implement track number support for mpris module #2280

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion py3status/modules/mpris.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
{state} playback status of the player
{time} played time of the song
{title} name of the song
{trackno} track number of the song
{nowplaying} now playing field provided by VLC for stream info

Button placeholders:
Expand Down Expand Up @@ -278,6 +279,10 @@ def metadata(self, metadata=None):

self._metadata["length"] = self._get_time_str(metadata.get(Metadata_Map.LENGTH))

# we are converting the attribute name to lowercase because although the spec
# says it's `xesam:trackNumber`, VLC exposes it as `xesam:tracknumber`
self._metadata["trackno"] = metadata.get(Metadata_Map.TRACK_NUMBER.lower());
ultrabug marked this conversation as resolved.
Show resolved Hide resolved

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

if not self._metadata.get("title"):
Expand Down Expand Up @@ -407,6 +412,7 @@ def post_config_hook(self):
"artist": None,
"length": None,
"title": None,
"trackno": None,
"nowplaying": None,
"time": None,
"state": None,
Expand Down Expand Up @@ -477,7 +483,7 @@ def post_config_hook(self):
self._color_inactive = self.py3.COLOR_CONTROL_INACTIVE or self.py3.COLOR_BAD

self._format_contains_metadata = False
self._metadata_keys = ["album", "artist", "title", "nowplaying", "length"]
self._metadata_keys = ["album", "artist", "title", "nowplaying", "length", "trackno"]
for key in self._metadata_keys:
if self.py3.format_contains(self.format, key):
self._format_contains_metadata = True
Expand Down