Instructables

Pandora's Box - An Internet Radio player made with a Raspberry Pi!

FeaturedContest WinnerContest Winner

Step 8: Putting it Together with BASH and Python

Now that the hardware is connected, some custom scripts will give us control over Pianobar, the LCD, and the buttons. Programmers will probably cringe, but for simplicity's sake I gave each of these files full permissions for each user (in the terminal, enter "chmod 777 x.xx" where x.xx is the filename). This lets a BASH program execute a Python script, for example.

AUTOSTART FILE:

The first step to creating these scripts is to edit the autostart file in the LXDE directory. Edit this file with:

sudo nano /etc/xdg/lxsession/LXDE/autostart

Now add two lines to the end:

pianobar
bash /home/pi/.config/pianobar/scripts/PandorasBox.sh


Save and exit, and your OS is configured to start pianobar at startup. It will also begin continuously polling for pushbuttons. 

PYTHON AND BASH SCRIPTS:
The scripts used to control the LCD and buttons are hosted in a Github repository. They can be retrieved through the following:

cd /home/pi/.config/pianobar
git clone git://github.com/AyMac/Pandoras-Box.git
cd Pandoras-Box
git pull origin
cd ..
cp -r /home/pi/.config/pianobar/Pandoras-Box/scripts/ .

Now that the scripts have been retrieved, only one step remains to create a working system. 

Final Step: Since one of the options is to randomly select a new station, the main script needs to know how many stations are on a user's Pandora account. (To figure this out, start Pianobar and press "s". This will list all the available stations). Now open the file /home/pi/.config/pianobar/scripts/ButtonPiper.sh and change the "n=" value to the number found above.

Your system should be complete! Please comment on this Instructable with any issues you have, and I will try to address them. The next step talks about making a case, but the system should be fully functional before this step.
 
Remove these adsRemove these ads by Signing Up
tayexdrums8 months ago
I have been struggling with getting this to successfully automatically start on boot for an entire day. I have tried putting the pianobar and bash /home/pi/.config/pianobar/scripts/PandorasBox.sh commands in multiple locations. I have tried putting them in the /etc/rc.local file, the ~./bashrc file, and the /etc/bash.bashrc file. The only one that seemed to "halfway" work was the ~/.bashrc file. The pianobar would start but the PandorasBox.sh script would not so was unable to use the buttons. Please help!
tenokage11 months ago
in the first paragraph, chmod 777 x.xx where x.xx is the filename, for which files? I also got an error when I tried to enter the last instruction given above (cp -r /home/pi/.config/pianobar/Pandoras-Box/scripts/.) where it said " cp: missing destination file operand after 'cp -r /home/pi/.config/pianoar/Pandoras-Box/scripts/." Any help would be greatly appreciated thanks
qbgroup1 year ago
Great project. Very nicely written. Thank you!
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!