Patiobar on raspberry pi

While at LinuxFest Northwest I picked up an Old Raspberry Pi from the Yard Sale. I didn't realise it was a Model A...took me a while to figure out a use for it, not much memory or processing power.

I installed RuneAudio on it but really just wanted Pandora. I found pianobar and the web interface, Patiobar and got them working. I did have to install a few things to get it working and it did involve some tricks with pacman. Probably could have ditched runeaudio but learning how to use arch again is fun.

pianobar had poor quality sound when I first started it, so I switched to the oss driver. Edit /etc/libao.conf and change default_driver to oss. Then run pianobar from the helper script aoss. I had to install libpulse as well to get that working.

Making them start automatically turned out to be a big hack so here's how...

Create a tmux startup script.

#!/bin/bash

export HOME=/root

#check if you can reach pandora.com
while /bin/true
do
        getent hosts pandora.com
        if [ $? == 0 ]; then
                break
        fi
done
tmux new-session -s pianobar -n pianobar -d
#tmux update-environment HOME
tmux send-keys -t 0 '/usr/bin/aopiano' enter
tmux new-window -t pianobar:1 -n Patiobar
tmux select-window -t pianobar:1
tmux send-keys -t 0 'cd /root/Patiobar; export HOME=/root; node index.js' enter

This checks to see if pandora.com is resolvable. The network-online.target wasn't working for me, the network was up but pandora.com wasn't yet resolvable, so pianobar would exit. The script starts tmux and creates two windows, in the first pianobar is run, in the second Patiobar. pianobar needs to be configured to load a station automatically or Patiobar will be sending the wrong input to it via the fifo.

The aopiano script is just the aoss script modified to start pianobar directly. I probably don't need it anymore, but already had it when I was testing.

#!/bin/sh

# A simple script to facilitate the use of the OSS compatibility library.
# Usage:
#       aoss <command> <command options and arguments>
LIB=lib
if [ -d /proc/asound ]; then
  prefix=/usr
  exec_prefix=${prefix}
  LD_PRELOAD=${exec_prefix}/\$LIB/libaoss.so${LD_PRELOAD:+:$LD_PRELOAD} exec /usr/bin/pianobar
else
  exec "$@"
fi
exit 1

So now on boot the raspberry waits for pandora to resolve, then starts tmux with pianobar and Patiobar running. The nice thing is that I can connect to the tmux session and control pianobar directly. I can also connect to the Patiobar session on port 3000 from any machine in the house.

Wordpress category: 

Add new comment

Markdown

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Refresh Type the characters you see in this picture. Type the characters you see in the picture; if you can't read them, submit the form and a new image will be generated. Not case sensitive.  Switch to audio verification.