I constantly listen to Pandora (even while I sleep). However one thing I’ve always disliked about Pandora was that it required Flash. You remember Flash, it’s that enormous resource hog that’s constantly crashing. Then I discovered Pianobar, the open-source Pandora client that runs in your terminal. Pianobar is chock full of features:
- play and manage (create, add more music, delete, rename, …) your stations
- rate played songs and let Pandora explain why they have been selected
- show upcoming songs/song history
- configure keybindings
- last.fm scrobbling support (external application)
- proxy support for listeners outside the USA
If you’re running Ubuntu, you can install Pianobar simply by typing sudo apt-get install pianobar
, and to launch it type pianobar
. If your on OS X there a few more steps:
curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/localThis will install the Homebrew package manager. Homebrew is like apt-get, except for OS X. Now type
brew install pianobar
to install Pianobar. That’s it! You can start enjoying music in your terminal.
Customization
We’re Super User’s, and that means we have a need to customize everything. That’s why you have that unicorn wallpaper. So how can we customize Pianobar? Well first of all, typing in your username and password every time you want to listen to music is annoying. Luckily you can create a config file for Pianobar to avoid this. Open your favorite text editor (cough gedit) and enter this:
user = lucas@ponyoverflow.com password = ilikeunicorns audio_format = mp3-hifiThis is pretty self explanatory. The first line is where your username will go and line two is for your password. The third option tells Pianobar to download high quality audio; if your on a slow connection you can omit this option. You’ll need to save this file in ~/.config/pianobar/ as config.
One feature I really like about the AdobeAIR client for Pandora are the notifications on song change. We can replicate this on Ubuntu using libnotify-bin (download via sudo apt-get install libnotify-bin
) or on OS X by using Growl (brew install growlnotify
). Now reopen the config file and add this line at the bottom:
Ubuntu: event_command = /home/myuser/bin/pianobar-notify
OS X: event_command = /Users/yourusername/bin/pianobar-notify.rbGrap the correct file for your operating system here: Ubuntu / OS X
Now that we have working notifications, it would be nice if we didn’t need that extra terminal window open all the time. To avoid this you can install Tilda. Tilda is a terminal that runs in the background; when you need it just press a shortcut key and you have a terminal, press again and it’s gone. To get Tilda just type sudo apt-get install tilda
.
Now we have successfully cut the cord that connected Mother Flash and Baby Pandora; in the process reclaiming precious memory.
Filed under Software
And Pithos is most excellent if you want a GUI tool.
Actually, you can install pianobar on Mac OS X via MacPorts.
sudo port install pianobar
What about windows? Is there any way to accomplish this through the command?
@KronoS: I’m not sure about Windows. I guess you could try it with cygwin.
I keep getting /!\ Cannot start eventcmd. (Permission Denied) for my notifications. I’ve tried marking the file as executable, but then I get /!\ Cannot start eventcmd. (Exec format error)
am I doing something wrong here?
Hm… After inserting a blank line in the file and renaming it to .sh I managed to get rid of the error messages, but notifications are simply not showing up.
@Bruce perhaps you should ask the question on Super User! 😉
@KronoS I will =). I just wanted to poke around a little more before going there.
Bruce, if you use the download button then the script contains invalid characters (windows new lines). You can remove them easily with vi: at a shell, type: vi ~/.config/pianobar/config Press : (colon) Type ‘% s/’ Press Ctrl+V, then Ctrl+M Type ‘//’
The bottom of the vi window should look like ‘:% s/^M//’ Then press enter. All the ^M’s should go away.
Type ‘:wq’ and press enter again to quit.
If you aren’t comfortable with vi then just copy & paste the script into gedit instead of using the download button.
Thanks for the tip Brian, I’m not Bruce (the original poster with this problem) but I’m still getting the error: /!\ Cannot start eventcmd. (Permission denied) even after ensuring I don’t have any wierd hidden characters in my config file or my .rb file.
My “/!\ Cannot start eventcmd” problem was just that I hadn’t added execute permissions to the .rb file.
I’ve since discovered: https://gist.github.com/832632/6bb39b85dda8f8212dc4b8bc6e7acd6b8c45d6eb which does both growl notifications and last.fm scrobbling.
Thank you for this! I used your instructions combined with a bit from the shell script from Isaac Hodes’ blog post (http://copperthoughts.com/p/lovely-pianobar/) and a Pandora icon I found on Google images (http://blog.caranddriver.com/wp-content/uploads/2011/01/Pandora-App-Icon.png) to add the album name and Pandora icon to the Growl notification.
Just drop the Pandora icon in .config/pianobar and change the growlnotify line to:
growlnotify -t "Now Playing" -m "#{songinfo['title']} on #{songinfo['album']}nby #{songinfo['artist']}" --image=/Users/yourusername/.config/pianobar/Pandora-App-Icon.png
Thanks again!
Great work! I just updated this script to include the album art from Pandora. Feedback welcome.
https://gist.github.com/1668755
Any thoughts on adding a “Tweet this song” menu option? It is available in the Flash player.
no need for all the growlnotify stuff. Try this notify script instead:
http://pastebin.com/gWie2TJq
Sorry, forgot to mention that notify is only appropriate for OSX