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.
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:
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:
git clone git://github.com/AyMac/Pandoras-Box.git
git pull origin
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.