def main(): meta = { 'artist': str(sh.playerctl('metadata', 'artist').wait()), #'album': str(sh.playerctl('metadata', 'album').wait()), 'track': str(sh.playerctl('metadata', 'title').wait()), } print(' {artist} - {track} '.format(**meta))
def now_playing(): META_FILE_REGEX=re.compile(b"xesam:url.+file://(.+)") ### Grab the URLEncoded file path from the 'playerctl meta' command command = sh.playerctl('metadata') from urllib.parse import unquote encoded_filepath = META_FILE_REGEX.search(command.stdout).groups()[0] filepath = unquote(encoded_filepath) filename = filepath.split('/')[-1] return '.'.join(filename.split('.')[:-1])
def previous(qtile): sh.playerctl('previous')
def next(qtile): sh.playerctl('next')
def stop(qtile): sh.playerctl('stop')
def play_pause(qtile): sh.playerctl('play-pause')