Pianobar: Setup Notification and get lyrics for now playing

Please look at my earlier post for install and configuring Pianobar.

I’m going to setup mac osx notification center to get notification of now playing song which will include Title, Artist and Album. Let’s go back to the Pianobar config file and add event_command as below. What we are doing here? get info from Pianobar of every event and run the specified script. In this case on every event it’s going launch the base script eventcommand.sh

event_command = /Users/yourusername/.config/pianobar/eventcommand.sh

Let’s create the file

touch ~/.config/pianobar/eventcommand.sh
nano ~/.config/pianobar/eventcommand.sh

Copy and the following in the editor and save it.


	while read L; do
	        k="`echo "$L" | cut -d '=' -f 1`"
	        v="`echo "$L" | cut -d '=' -f 2`"
	        export "$k=$v"
	done < <(grep -e '^\(title\|artist\|album\|stationName\|pRet\|pRetStr\|wRet\|wRetStr\|songDuration\|songPlayed\|rating\|songDuration\|songPlayed\|coverArt\|stationCount\|station[0-9]\+\)=' /dev/stdin)

	case "$1" in
			/usr/bin/terminal-notifier -subtitle  "Artist: $artist" -message "Album: $album" -title "$title"

Make it executable

cd ~/.config/pianobar && chmod +x eventcommand.sh && mkfifo ctl

We have configured to get the notification but not yet lyrics. Move on further if you need lyrics.

Get lyrics

It’s hard to get lyrics directly from Pandora as I think that their API doesn’t support lyrics, but people wrote HTML extractor to get lyrics which can be found here. But I’m going to use glyr to do this job.

I followed the wiki page to compile glyr. I’ll walk the through steps that I worked well. You need to install libintl from here then follow the steps below.

In my case MacPorts always works

sudo port install sqlite3
install cmake
brew install glib

or do with Homebrew.

brew install sqlite3
brew link --force sqlite
brew install cmake
brew install glib

Download glyr from here and extract it.

cd glyr
make && sudo make install

Now you can launch glyr with glyrc and update eventcommand.sh file with the following which includes the above notification.


while read L; do
        k="`echo "$L" | cut -d '=' -f 1`"
        v="`echo "$L" | cut -d '=' -f 2`"
        export "$k=$v"
done < <(grep -e '^\(title\|artist\|album\|stationName\|pRet\|pRetStr\|wRet\|wRetStr\|songDuration\|songPlayed\|rating\|songDuration\|songPlayed\|coverArt\|stationCount\|station[0-9]\+\)=' /dev/stdin)

case "$1" in
        echo -e "glyrc lyrics -a \"$artist\" -t \"$title\" -b \"$album\" -w /tmp/" > "$nowplaying"
		/usr/bin/terminal-notifier -subtitle  "Artist: $artist" -message "Album: $album" -title "$title"

The above script writes out put as lyrics.sh on every event i.e., when ever new song plays. If you want to look at the lyrics of the “Now Playing Song” then open a new tap in your terminal and run the following.

sh ~/.config/pianobar/lyrics.sh

We all done.

Install pianobar and run it under proxy server “tor”

Why Pianobar

Well, do you know Pandora uses flash? if you open their web in your browser then your system is going to cry! and if you have less resource memory & CPU like then you won’t like flash in your browser.

There are more issues, like the web plays adds and audio has low bit-rate i.e., low quality. If you need high quality music i.e., 190 kbps and without any adds then you need a subsription.

But you can luckly get rid of adds and get high bit-rate audio via Pandora API. Here comes Pianobar, a free command line based client that does all you need.

Again, I followed few blogs to get it running, few of them are here; Instructables,

On linus

sudo apt-get install pianobar

on Mac

Easier way is to use either MacPorts or Homebrew. To install via MacPorts to the following

sudo port install pianobar

I’ll guide you to use Homebrew. first install Homebrew source

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
brew install pianobar

If you get error on the above installation then may be the link is dead and you need to get the updated URL. People also use different way to install them, here is another way. source

curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local

Compile manually; first install depenties and then Pianobar according to this soruce

sudo port install libao faad2 libmad cmake git-core
git clone git://github.com/PromyLOPh/pianobar.git
cd pianobar
cmake . && make && sudo make install

Now you can launch Pianobar with


It’ll ask you to enter user name and password, following station name, like below

Welcome to pianobar! Press ? for a list of commands.
[?] Username:
[?] Password:
(i) Login… Ok.
(i) Get stations… Ok.
0) some name Radio
1) some name Radio
2) some name Radio
3) some name Radio

[?] Select station:

After the login you can press ? to view the action keys, like pressing n can choose next song.

Configure Pianobar

We can configure Pianobar with user name and password in a text file where we could also specify to use proxy and even more. By default Pianobar will look for a configuration file under ~/.config/pianobar/config, so all we have to do is to create a config file in that location.

Create .config under your home directory like below if you don’t have one.

mkdir -p ~/.config/pianobar
cd ~/.config/pianobar
touch config
nano config

Let’s add some details to the cofig file

tls_fingerprint = 2D0AFDAFA16F4B5C0A43F3CB1D4752F9535507C0
user = myemail@mail.com
password = mypassword

At this moment I don’t have more details on tls_fingerprint, but may be in future I’ll have some.

If you run pianobar on your terminal, it’s going login automatically, wow! that’s nice. Still we can do more here, let’s move on further.

Run under Proxy

If you are located outside of US then you want to use free/paid proxy server to get access to Pandora, look at my previous post deals with free proxie servers. Remember that Pianobar can handle http proxy but not the SOCKS.

Add the following at the bottem of your config file.

control_proxy = http://xxx.xxx.xxx.xxx:80

Replace xxx.xxx.xxx.xxx with the IP your found on free proxy sites and also the port number 80. Now you should able to use Pianobar from outside of US.

Ok, that looks fine, but hey! don’t you think it’s silly to edit config file on every launch?, yes it’s. There is work around for this, you can configure tor to automatically pickup the proxy.

Configure tor

For installing tor look at my earlier post, if you run it then you’ll see something like below on ~5-th line;

[notice] Opening Socks listener on

So you could cofigure your Pianobar to listen to port 9050, you may expect it’s all done, but it’s not going to work because tor works on SOCKS and Pianobar doesn’t handle SOCKS and required http proxy. So what we are going to do? there are scripts around which does listen to SOCKS and forwards it to http proxy. It was very hard for me to get one working. I was trying pianobarproxy, delegate, Polipo and few more. None of them worked initially but I found a working method with Polipo and I’ll explain you here. It’s taken from different resources found here and in superuser.Install Polipo from Homebrew.

brew install Polipo

Now we need to configure Polipo to listen to tor’s port 9050 and forward it to localhost. Create a text file anywhere with the following info,

socksParentProxy =

Now we can tell Polipo to use this configuration file as belwo.

polipo -c ~/Downloads/config.txt

You can also add configuration file to the location /etc/polipo/config then you don’t need to specify the configuration file (source). You can also find a template here. You can do this as below.

cd /etc
sudo mkdir polipo
sudo touch config
sudo nano config

In nano editor copy and the paste the follwing and press ctrl+o and ctrl+x.

socksParentProxy =

Remember that Polipo default listening port is 8123 and we have add this port to Pianobar config file. Add this info.

control_proxy =

We all done, open three tabs on terminal, on one type tor, in the next one type the above Polipo command and in the last tab type pianobar, you must see Pianobar running.