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

Library function to listen to player names appearing and vanishing #100

Closed
acrisci opened this issue Oct 13, 2018 · 1 comment
Closed

Library function to listen to player names appearing and vanishing #100

acrisci opened this issue Oct 13, 2018 · 1 comment
Milestone

Comments

@acrisci
Copy link
Member

acrisci commented Oct 13, 2018

This is currently done in the cli, but it would be good to have it in the common library to make it more usable for scripts that follow players coming and going. I think this is probably fairly essential to any use case for the library.

It should look something like this (but in C of course):

def on_player_name_appeared(name, data):
    # start managing your player here
    print('player appeared: {}'.format(name))

def on_player_name_vanished(name, data):
    # stop managing your player here
    printf('player name vanished: {}'.format(name))

user_data = {}

Playerctl.watch_player_names(on_player_appeared, on_player_vanished, user_data)

GLib.main_loop().run()
@acrisci acrisci added this to the 1.0.0 milestone Oct 15, 2018
@acrisci
Copy link
Member Author

acrisci commented Oct 20, 2018

Finished.

@acrisci acrisci closed this as completed Oct 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant