Merge pull request #251 from DanielVoogsgerd/feature-select-player
Feature select playerpull/256/head
commit
30725824d0
|
@ -38,6 +38,13 @@ def on_metadata(player, metadata, manager):
|
|||
sys.stdout.flush()
|
||||
|
||||
|
||||
def on_player_appeared(manager, player, selected_player=None):
|
||||
if player is not None and player.name == selected_player:
|
||||
init_player(manager, player)
|
||||
else:
|
||||
logger.debug('New player appeared, but it\'s not the selected player, skipping')
|
||||
|
||||
|
||||
def on_player_vanished(manager, player):
|
||||
logger.info("Player has vanished")
|
||||
sys.stdout.write("\n")
|
||||
|
@ -67,6 +74,9 @@ def parse_arguments():
|
|||
# Increase verbosity with every occurance of -v
|
||||
parser.add_argument('-v', '--verbose', action="count", default=0)
|
||||
|
||||
# Define for which player we're listening
|
||||
parser.add_argument('--player')
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
|
@ -87,13 +97,19 @@ def main():
|
|||
manager = Playerctl.PlayerManager()
|
||||
loop = GLib.MainLoop()
|
||||
|
||||
manager.connect('name-appeared', init_player)
|
||||
manager.connect('name-appeared', lambda *args: on_player_appeared(*args, arguments.player))
|
||||
manager.connect('player-vanished', on_player_vanished)
|
||||
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
signal.signal(signal.SIGTERM, signal_handler)
|
||||
|
||||
for player in manager.props.player_names:
|
||||
if arguments.player is not None and arguments.player != player.name:
|
||||
logger.debug('{player} is not the filtered player, skipping it'
|
||||
.format(player=player.name)
|
||||
)
|
||||
continue
|
||||
|
||||
init_player(manager, player)
|
||||
|
||||
loop.run()
|
||||
|
|
Loading…
Reference in New Issue