mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[scripts/playerctl-simple-menu] add a message for when no players are detected
This commit is contained in:
parent
4c2dd033a6
commit
c127b901ef
1 changed files with 43 additions and 34 deletions
|
@ -130,18 +130,23 @@ def iter_actions_for_player(player):
|
|||
|
||||
root_menu = Gtk.Menu()
|
||||
|
||||
for player_name in sorted(
|
||||
player_names = sorted(
|
||||
Playerctl.list_players(),
|
||||
key=lambda player_name: (
|
||||
-PLAYER_NAME_PRIORITIES.get(player_name.name, 0),
|
||||
player_name.instance,
|
||||
),
|
||||
):
|
||||
)
|
||||
|
||||
if len(player_names) > 0:
|
||||
for player_name in player_names:
|
||||
player = Playerctl.Player.new_from_name(player_name)
|
||||
|
||||
player_menu_item = Gtk.ImageMenuItem.new_with_label(player_name.instance)
|
||||
|
||||
player_icon_name = PLAYER_ICON_NAME_FIXES.get(player_name.name, player_name.name)
|
||||
player_icon_name = PLAYER_ICON_NAME_FIXES.get(
|
||||
player_name.name, player_name.name
|
||||
)
|
||||
player_icon = Gtk.Image.new_from_icon_name(player_icon_name, Gtk.IconSize.MENU)
|
||||
player_menu_item.set_image(player_icon)
|
||||
|
||||
|
@ -177,6 +182,10 @@ for player_name in sorted(
|
|||
|
||||
player_menu_item.set_submenu(actions_menu)
|
||||
root_menu.append(player_menu_item)
|
||||
else:
|
||||
menu_item = Gtk.MenuItem.new_with_label("No players were detected!")
|
||||
menu_item.set_sensitive(False)
|
||||
root_menu.append(menu_item)
|
||||
|
||||
|
||||
root_menu.connect("selection-done", Gtk.main_quit)
|
||||
|
|
Loading…
Reference in a new issue