Skip to content

Latest commit

 

History

History
55 lines (42 loc) · 1.26 KB

README.org

File metadata and controls

55 lines (42 loc) · 1.26 KB

Setup

Add to your .config/pianobar/config this line:

event_command = ~/.config/pianobar/event_command.py

event_command.py should be executable and look like this:

#!/usr/bin/python

import os
import sys
from 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')

lines = sys.stdin.readlines()
cmd = sys.argv[1]

if cmd == 'songstart':
    with open(fn, 'w') as f:
        title = None
        artist = None
        for line in lines:
            if "title" in line:
                split = line.split("=")
                title = split[1]
            elif "artist" in line:
                split = line.split("=")
                artist = split[1]
        if title and artist:
            nowplaying = "{} - {}".format(artist, title).replace("\n", "")
            f.write(nowplaying)

Usage

Put:

(load-module "pianobar")

In your ~/.stumpwmrc

Then you can use “%P” in your modeline format for now playing info.

You can customize the path to the nowplaying file with pianobar-now-playing-path