unix - How do I retrieve the current song name and time left from pianobar using python? -
i'm creating alarm clock gui using tkinter , python on raspberry pi. when alarm goes off want start playing pianobar. can enough, want display name of song on gui, , cannot figure out how current song being played. have tried using pipes "|", , redirecting ">" have gotten nowhere. advice help.
you need use event command interface. man page:
an example script can found in contrib/ directory of pianobar's source distribution.
~/.config/pianobar:
user = <username> password = <password> (although i'd suggest password_command) event_command = ~/.config/pianobar/event_command.py ~/config/event_command.py
#!/usr/bin/env python import os import sys os.path import expanduser, join path = os.environ.get('xdg_config_home') if not path: path = expanduser("~/.config") else: path = expanduser(path) fn = join(path, 'pianobar', 'nowplaying') info = sys.stdin.readlines() cmd = sys.argv[1] if cmd == 'songstart': open(fn, 'w') f: f.write("".join(info)) this write song information ~/.config/pianobar/nowplaying when new song starts (there other events available in manpage). can parse using choice of tools acquire song title.
Comments
Post a Comment