mpris-status: Don't fail when no media players are present
This commit is contained in:
parent
382884f420
commit
a8887a7f9e
@ -89,13 +89,16 @@ def status_icon(player: Player) -> str:
|
||||
players = [Player(dbus_interface_info={"dbus_uri": uri}) for uri in get_players_uri()]
|
||||
|
||||
players.sort(key=status_key)
|
||||
active_player_id = get_player_id_from_uri(players[0]._dbus_interface_info.uri)
|
||||
print(
|
||||
if len(players) > 0:
|
||||
active_player_id = get_player_id_from_uri(players[0]._dbus_interface_info.uri)
|
||||
print(
|
||||
"<txt>"
|
||||
+ (f"[{ len(players) }] " if len(players) > 1 else "")
|
||||
+ format_player(players[0], short=True)
|
||||
+ "</txt>"
|
||||
)
|
||||
print(f"<txtclick>playerctl --player={ active_player_id } play-pause</txtclick>")
|
||||
print(f"<icon>{ status_icon(players[0]) }</icon>")
|
||||
print("<tool>" + "\n".join(format_player(player) for player in players) + "</tool>")
|
||||
)
|
||||
print(f"<txtclick>playerctl --player={ active_player_id } play-pause</txtclick>")
|
||||
print(f"<icon>{ status_icon(players[0]) }</icon>")
|
||||
print("<tool>" + "\n".join(format_player(player) for player in players) + "</tool>")
|
||||
else:
|
||||
print("<txt>No media players</txt>")
|
||||
|
Loading…
Reference in New Issue
Block a user