I like having Pandora going pretty much all the time, be it Bach when I’m coding, Techno for sysadmin tasks, or indulging my shameful pop music addiction. I wanted a way to control Pandora without having to drop out of the shell. I wanted it for my Mac, but lucked out and found one that works across all the platforms I use. Pianobar is a command line Pandora client and it works in Mac and Linux. (And Windows too.)
I was having a little trouble building it in Snow Leopard using the instructions from here, when I discovered that it’s already available in MacPorts. So I installed it with:
In Linux, you can find links to the repos for your distro of choice on the Pianobar website.
Next, I wanted it to login automatically and start playing when I launched it. On Mac, you can create a config file at ~/.config/pianobar/config, with contents similar to the following:
password = s3cR3t_sQu1RR3L
user = email@example.com
To get the station ID for the autostart_station parameter:
- Run pianobar
- Log in manually
- Launch your favorite station
- Hit i to see the station and song info.
- The station ID will be in parentheses after the station name.
After you’ve got your file saved, you should be able to launch pianobar and have it start playing auto-magically.
Now, my next step was to use at so I could start pianobar at a given time and use it as an alarm clock.
You need to enable atrun on your Mac to use at to schedule jobs. (It’s enabled by default on most Linux distros.) You can schedule the launch like so:
pianobar #hit enter
If you start pianobar with at, it’s not on an interactive shell so you have no way to interact with it, or so I thought. You can create a fifo file to pass controls to the process:
Once you have that, you can control pianobar by echoing commands into the fifo:
echo p > ~/.config/pianobar/ctl
echo q > ~/.config/pianobar/ctl
Hopefully that’s food for though enough to get you started. Enjoy.