Dec 8, 2012

Controlling pianobar Pandora client with keyboard shortcuts

I've been wanting to get pianobar, a CLI for Pandora, installed on a raspberry pi as a stand-alone player. This post talks about "baby steps" on the way there, a work-in-progress.
First, since I'm running Ubuntu 10.04, I had to install from source. Make sure you have the following dependencies:
sudo apt-get install install build-essential
sudo apt-get install libjson0-dev
Download from the pianobar github and untar/unzip.
cd to the pianobar download folder
Do the following:
make
sudo make install

Test it out just by running:
pianobar
This should bring up your stations and start playing, if you have your login configured properly.
You can find a list of commands by pressing the "?" key. Obviously, you can enter these commands in the same terminal session as pianobar.
But, as a step toward getting a raspberry pi interface going, I wanted to be able to send the commands from some other terminal session. That would sort of emulate sending from a python program and/or serial connection.
To do this, you need to create a FIFO file.  Here's how:
cd ~/.config/pianobar
mkfifo ctl
Now, when you issue the commands (from another terminal session):
echo "i" > ~/.config/pianobar/ctl       # for example, song title
You will get back info on the playing song, although this will be in the original terminal session.
More on this at the Copper Thoughts blog, and a better way to do actual keyboard shortcuts.

















No comments:

Post a Comment