Autostart, Clickwheel, Spotify Credentials... How I made the screen work
See original GitHub issueSo, I’ve spent more nights than I should have working on this, my first Raspberry Pi project.
Here are the things I’ve done following the README file and trying to make it work for myself…
For the ones that don’t know, you can code everything from your PC/Mac terminal and you can copy/paste the codes. I didn’t know for the first days.
Details on what works and what doesn’t at the end of this…
So:
Install Raspberry Pi OS Lite to your Pi and then configure your WiFi on first boot
-
Install Updates
sudo apt-get update
sudo apt-get upgrade
-
Install Dependencies
sudo apt install python-setuptools python3-setuptools
sudo apt install python3-pip
sudo curl-sL https://dtcooper.github.io/raspotify/install.sh | sh
sudo apt install install xorg
sudo apt-get install python3-tk
sudo apt-get install redis-server
sudo apt-get install openbox
sudo apt-get install lightdm
sudo apt-get install x11-xserver-utils
-
Install Dependencies
pip3 install -r requirements.txt
This command didn’t work. So I ran the following:sudo apt-get install git
git clone https://github.com/dupontgu/retro-ipod-spotify-client
After this:cd /home/pi/retro-ipod-spotify-client/frontend/
To finally run this…pip3 install -r requirements.txt
-
Install pi-btaudio
git clone https://github.com/bablokb/pi-btaudio.git
cd pi-btaudio
sudo tools/install
All worked fine. For bluetooth pairing and instructions, go to https://github.com/bablokb/pi-btaudio
- Install PiGPIO
wget https://github.com/joan2937/pigpio/archive/master.zip
unzip master.zip
cd pigpio-master
make
sudo make install
I don’t know if it works because I haven’t been able to use the Clickwheel. Still don’t know it it’s a hardware or software issue…
-
Setup Spotify API Create a Spotify Developer Account, then create an app where you will get your Client ID, Client Secret, and create a Redirect URI. I recommend watching this video and try to make something like the link on README. I think it hasn’t worked 100% right for me though…
-
Disable Screen Blanking
sudo raspi-config
Display Option > Screen Blanking > OFF / Disable -
Disable Cursor and Screen Savers Add or Create and Add this:
sudo nano /root/.bash_profile
Then: ‘#!/bin/bash’[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor
# Disable any form of screen saver / screen blanking / power management
xset s off
xset s noblank
-
Configure xinitrc
sudo nano /etc/X11/xinit/xinitrc
Inside, make sure the following is there:#!/bin/sh
# /etc/X11/xinit/xinitrc
# global xinitrc file, used by all X sessions started by xinit (startx)
# invoke global X session script
#. /etc/X11/Xsession'
exec openbox-session #-> This is the one that launches Openbox ;)` -
Run “spotifypod.py” with Autostart
sudo nano /etc/xdg/openbox/autostart
and add the following command to launch spotifypod.py: I made some changes and didn’t use the /fork/ folder as in READMEcd /home/pi/retro-ipod-spotify-client/frontend/
sudo -H -u pi python3 spotifypod.py &
sudo /home/pi/retro-ipod-spotify-client/clickwheel/click &
There is noclick
so in order to get that:cd /home/pi/retro-spotify-client/clickwheel
gcc -Wall -pthread -o click click.c -lpigpio -lrt
It returns some warnings but everything is fine. I guess… -
Spotify Credentials ‘sudo nano /etc/xdg/openbox/environment’ Add you credentials:
export SPOTIPY_CLIENT_ID='your_SPOTIPY_CLIENT_ID'
export SPOTIPY_CLIENT_SECRET='your_SPOTIPY_CLIENT_SECRET'
export SPOTIPY_REDIRECT_URI='your_SPOTIPY_REDIRECT_URI'
-
Syncronize Spotify Data Synchronizing Spotify data! Last but not least, if you want to make sure all your playlists artists, etc are synchronized every time you turn on your Spotypod, you can simply modify the script
view_model.py
with the following at line 16:#spotify_manager.refresh_devices()
spotify_manager.refresh_data()
instead of calling refresh_device
, you can execute refresh_data
. This will sync all your data and then will execute refresh.devices
. This will make the boot up way slower! but it will synchronize every single time you switch on 😃. If you don’t run at least once refresh_data()
no playlist, artist or anything related with your account will be displayed!
I had errors with this part so I left it as it was…
- Configure Raspotify
sudo nano /etc/default/raspotify
Uncomment and fill the following line:OPTIONS="--username <USERNAME> --password <PASSWORD>"
And maybe you want also to consider the following:# The displayed device type in Spotify clients.
# Can be "unknown", "computer", "tablet", "smartphone", "speaker", "tv",
# "avr" (Audio/Video Receiver), "stb" (Set-Top Box), and "audiodongle".
DEVICE_TYPE="smartphone"
All good. I also changed the Device Name
- Display Configuration!
sudo nano /boot/config.txt
uncomment (erase #):sdtv_mode=2
comment add (#)hdmi_force_hotplug=1
then add:hdmi_ignore_hotplug=1
After this if it throws error for displaying spotifypod.py
try the following command:
export DISPLAY=:0.0
So that’s what I’ve got. The app doesn’t autostart. When I start it I get the frontend screen that shows NOW PLAYING when I play a song on my phone. I still haven’t been able to work with the clickwheel, it is running with no errors apparently, but it doesn’t work with my clickwheel at least so I haven’t tried the app on itself. I connected the Pi to my bluetooth speaker and from my phone I used the Pi as a Remote Device and I got Spotify audio out of it. Is it able to choose it’s own songs and play them, I still don’t know. I hope this works for someone and if anybody has any info on how to solve the rest of this, please share hahaha.
Cheers and thanks @dupontgu for this fun project.
Issue Analytics
- State:
- Created 3 years ago
- Comments:27 (5 by maintainers)
Bitte sehr!
@theswz I had to temporarily table this project as the peak of the semester hit, so I haven’t made much progress since my last post.
The most recent Spotify credential error I received said that the program couldn’t the browser to verify the URI.
I connected a mouse to the pi and when it boots to the blank screen with a mouse icon I was able to right click to access a drop down menu and run the midori browser from there. I made a bit of progress trying to get the Spotify credentials to authorize there, but I was struggling because I had to keep alternating between having the keyboard and the mouse plugged in and the pi would reboot if I switched them too many times. (I bought a usb splitter, but I haven’t had time to work on the project since then).
The same drop down menu I was running the midori browser from also has a terminal option listed. I’ve read elsewhere in these forums that some people had more success getting the Spotipy program to run in there.
If you figure it out, please share the secret! I’m hoping to pick the project back up in the next week or so.