stumpwm.stumpwm-contrib/modeline/pianobar
2023-09-05 22:30:33 -04:00
..
package.lisp Add Pianobar modeline support 2023-09-05 19:25:55 -04:00
pianobar.asd Some fixes 2023-09-05 19:28:23 -04:00
pianobar.lisp Minor fixes 2023-09-05 19:38:11 -04:00
README.org Respecting org-mode preferred indentation 2023-09-05 22:30:33 -04:00

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