dupontgu / retro-ipod-spotify-client

The software that powers the sPot: a 4th generation "Click Wheel" iPod with a full Spotify client.
Apache License 2.0
920 stars 93 forks source link

Openbox and Tkinter driving me crazy :s #9

Open rsappia opened 3 years ago

rsappia commented 3 years ago

Do not take the following steps below as reference, since all these steps are probably not 100% ok. The right steps have been updated in the main Readme file!


Hi there, I am having a hard time trying to setup Openbox tu show the Tkinter output. Has anyone managend to configure this properly on a raspberry pi zero?

So far I have manage to get running a small 2." SPI display using fbcp-ili9341

This is what I have done so far:

Since I am using the lite version of raspbien, I installed some extra packages: sudo apt install xorg sudo apt-get install lightdm

In raspi-config: Console Autologin

In rc.local added before exit 0 the following line: startx &

Configure xinitrc

sudo nano /etc/X11/xinit/xinitrc

Comment this line

. /etc/X11/xsession

and add this line to start openbox exec openbox-session

Run "spotifypod.py" with autostart

sudo nano /etc/xdg/openbox/autostart

and add the following command to launch spotifypod.py

sudo -H -u pi python3 /somewhere/over/the/rainbow/spotifypod.py &

in sudo nano /etc/xdg/openbox/environment I set all the variables needed to run spotifypod.py ( SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET,SPOTIPY_REDIRECT_URI)

As result I get the following:

X.Org X Server 1.20.4 X Protocol Version 11, Revision 0 Build Operating System: Linux 5.4.0-54-generic armv8l Raspbian Current Operating System: Linux raspberrypi 5.10.11+ #1399 Thu Jan 28 12:02:28 GMT 2021 armv6l Kernel command line: coherent_pool=1M 8250.nr_uarts=0 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 bcm2708_fb.fbwidth=320 bcm2708_fb.fbheight=240 bcm2708_fb.fbswap=1 smsc95xx.macaddr=HI:TH:ER:EC:DD:E9 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000 console=ttyS0,115200 console=tty1 root=PARTUUID=2386ac2f-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait Build Date: 15 January 2021 02:03:57PM xorg-server 2:1.20.4-1+rpt2+deb10u3 (https://www.debian.org/support) Current version of pixman: 0.36.0 Before reporting problems, check http://wiki.x.org to make sure that you have the latest version. Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice, (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown. (==) Log file: "/var/log/Xorg.1.log", Time: Mon Feb 8 22:27:43 2021 (==) Using system config directory "/usr/share/X11/xorg.conf.d" InitSPI done Relevant source display area size with overscan cropped away: 320x240. Source GPU display is 320x240. Output SPI display is 320x240 with a drawable area of 320x240. Applying scaling factor horiz=1.00x & vert=1.00x, xOffset: 0, yOffset: 0, scaledWidth: 320, scaledHeight: 240 Creating dispmanX resource of size 320x240 (aspect ratio=1.333333). GPU grab rectangle is offset x=0,y=0, size w=320xh=240, aspect ratio=1.333333 All initialized, now running main loop... Openbox-Message: Unable to find a valid menu file "/var/lib/openbox/debian-menu.xml"

(process:627): WARNING : 22:27:46.829: xdg-autostart.vala:125: Error: Error opening directory ?/root/.config/autostart?: No such file or directory

Message: 22:27:46.838: xdg-autostart.vala:39: Processing /etc/xdg/autostart/at-spi-dbus-bus.desktop file. Message: 22:27:46.855: xdg-autostart.vala:94: Launching: /usr/lib/at-spi2-core/at-spi-bus-launcher --launch-immediately (at-spi-dbus-bus.desktop) Message: 22:27:46.858: xdg-autostart.vala:39: Processing /etc/xdg/autostart/xdg-user-dirs.desktop file. Message: 22:27:46.896: xdg-autostart.vala:94: Launching: xdg-user-dirs-update (xdg-user-dirs.desktop) Failed to launch bus: Failed to connect to session busNo protocol specified No protocol specified

All what I get is a black screen with a mouse pointer... In my PC I have managed to make it run and get to see the manues an navigate. With tthe RPI Zero, it looks like I am missing one or several pconfigurations to link Tkinter properly with openbox.. Any help would be very appreciated!!

dupontgu commented 3 years ago

@rsappia I'll have to look closer at my config, but in the meantime - have you tried running it from a terminal inside OpenBox? You might get a more helpful error message. I installed xterm, and then set it to be the default terminal for OpenBox. Then, when you right click within OpenBox (the black screen), you should have an option to launch it.

I also have in my (admittedly sparse) notes that I had to install x11-xserver-utils: sudo apt-get install x11-xserver-utils

rsappia commented 3 years ago

Thanks for your tip @dupontgu it was just a wrong path in one of my scripts

PSX_20210209_105758.jpg

Next stop, clickwheel!

By the way...Thanks a lot for sharing! This is an awesome project and I am actually glad that there is no complete guide, otherwise it wouldn't be so much fun involved in just doing copy paste :) I am learning a lot!

paulomurray commented 3 years ago

rsappia -- what was the wrong path - do tell do tell :)

rsappia commented 3 years ago

@paulomurray silly mistake... I was launchig the script like this:

python3 frontend/spotifypod.py

at some point of the execution, the script couldn't find the png files

it was solved by launchig the script directly from the frontend folder.. this wasn't a problem when I was testing in my PC's console :/

Now I am fighting against screen blanking haha, I havent reached the right xset configuration to avoid that.. right after that... clickwheeeel!!!

paulomurray commented 3 years ago

What are your tips and tricks for getting the spotify authorization working

I am stuck on that

From: rsappia notifications@github.com Sent: Tuesday, February 9, 2021 11:12 AM To: dupontgu/retro-ipod-spotify-client retro-ipod-spotify-client@noreply.github.com Cc: paulomurray paul@murraynation.com; Comment comment@noreply.github.com Subject: Re: [dupontgu/retro-ipod-spotify-client] Openbox and Tkinter driving me crazy :s (#9)

@dupontgu https://github.com/dupontgu silly mistake... I was launchig the script like this:

python3 frontend/spotifypod.py

at some point of the execution, the script couldn't find the png files

it was solved by launchig the script directly from the frontend folder.. newbie mistake :) 🙈

Now I am fighting against screen blanking haha, I havent reached the right xset configuration to avoid that.. right after that... clickwheeeel!!!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dupontgu/retro-ipod-spotify-client/issues/9#issuecomment-776173604 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ASZAO7WZB3NVJNCFIKNKGG3S6GCHXANCNFSM4XJ3NLWA . https://github.com/notifications/beacon/ASZAO7T7GKVTSGZNXCERLWLS6GCHXA5CNFSM4XJ3NLWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFZBXQJA.gif

Archipollo commented 3 years ago

paulomurray -- I don't think this is the right thread for this, but what you can try is to either export your Client_id, Client_Secret, and Redirect_URI or hardcode it into spotify_manager.py like this: In line 68 sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id='XXXXXXXX', client_secret='XXXXXXXX', redirect_uri='http://127.0.0.1', scope=scope))

It's important that you expand the scope with additional permissions, as some more are needed than in the basecode. Also, what helped me is for the Authentication Process, I commented out the 'has_internet' variable as well as the 'check_internet' class, because that lead to double requests. But once you get redirected to the spotify permissions page, you only need to copy over the link from the page after you grant those permissions into the console and you should get a working .cache file in your folder.

One more thing, don't forget to set the redirect_uri in your spotify developer application. This needs to be the same URI as in your code, in this example http://127.0.0.1.

Hope this helps, also huge thanks @dupontgu for this project, it has been very fun setting this up myself, even if I haven't finished it yet!

paulomurray commented 3 years ago

hugs

--

paulomurray -- I don't think this is the right thread for this, but what you can try is to either export your Client_id, Client_Secret, and Redirect_URI or hardcode it into spotify_manager.py like this: In line 68 sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id='XXXXXXXX', client_secret='XXXXXXXX', redirect_uri='http://127.0.0.1', scope=scope))

It's important that you expand the scope with additional permissions, as some more are needed than in the basecode. Also, what helped me is for the Authentication Process, I commented out the 'has_internet' variable as well as the 'check_internet' class, because that lead to double requests. But once you get redirected to the spotify permissions page, you only need to copy over the link from the page after you grant those permissions into the console and you should get a working .cache file in your folder.

One more thing, don't forget to set the redirect_uri in your spotify developer application. This needs to be the same URI as in your code, in this example http://127.0.0.1.

Hope this helps, also huge thanks @dupontgu https://github.com/dupontgu for this project, it has been very fun setting this up myself, even if I haven't finished it yet!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dupontgu/retro-ipod-spotify-client/issues/9#issuecomment-776259229 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ASZAO7SCWDVR7BJB4Y5RRTLS6GTAJANCNFSM4XJ3NLWA . https://github.com/notifications/beacon/ASZAO7VSGMYGG57WYDGGBFDS6GTAJA5CNFSM4XJ3NLWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFZCMNHI.gif

rsappia commented 3 years ago

Hi @paulomurray , all what @Archipollo explained is what I did. Dont forget to declare de environment variables and pay close attention to the error messages, they are extremely helpful :)

chonnymon commented 3 years ago

@rsappia

@paulomurray silly mistake... I was launchig the script like this:

python3 frontend/spotifypod.py

at some point of the execution, the script couldn't find the png files

it was solved by launchig the script directly from the frontend folder.. this wasn't a problem when I was testing in my PC's console :/

Now I am fighting against screen blanking haha, I havent reached the right xset configuration to avoid that.. right after that... clickwheeeel!!!

Thanks for posting your steps so far, this has been a great help to me.

following your steps above I have got openbox to launch with black screen and mouse pointer

if I use the xterm terminal and navigate to the frontend folder I can launch spotifypod.py but openbox isn't launching it on its own

did you have to change the line sudo -H -u pi python3 /somewhere/over/the/rainbow/spotifypod.py &

Would you mind sharing your fix?

Thanks

efernan commented 3 years ago

Thanks for your tip @dupontgu it was just a wrong path in one of my scripts

PSX_20210209_105758.jpg

Next stop, clickwheel!

By the way...Thanks a lot for sharing! This is an awesome project and I am actually glad that there is no complete guide, otherwise it wouldn't be so much fun involved in just doing copy paste :) I am learning a lot!

Hi!

@rsappia Good job! I also bought a “Waveshare 2inch LCD Module” to test the wonderful work of @dupontgu but you have been faster and more efficient than me… ;-)

I have managed to see the demo python program from the web: https://www.waveshare.com/wiki/2inch_LCD_Module?Amazon

But I can't see the raspberry desktop.

You have commented that you use the frcp-ili9341 driver, but I can't get it to work. I have followed the instructions that they comment on the driver's website: https://github.com/juj/fbcp-ili9341

but I have not been successful...I have tried various options compiling the binary like this:

_cmake -DST7789VW=ON -DGPIO_TFT_RESET_PIN=7 -DBACKLIGHT_CONTROL=ON -DGPIO_TFTBACKLIGHT=12 ..

I'm a little frustrated, can you show me the way?

Thanks in advance!!! Greetings.

rsappia commented 3 years ago

@efernan I was also there mate! you may want take a look here ;)

https://github.com/juj/fbcp-ili9341/issues/125

These are the one I used for CMAKE (dont forget to adapt the pinout to your case) :

cmake -DST7789=ON -DGPIO_TFT_DATA_CONTROL=24 -DGPIO_TFT_RESET_PIN=25 -DSPI_BUS_CLOCK_DIVISOR=30 -DSTATISTICS=0 -DDISPLAY_BREAK_ASPECT_RATIO_WHEN_SCALING=ON -DUSE_DMA_TRANSFERS=OFF ..

I didnt use the backlight control feature with PWM, I just wired the backligth to 3.3V

rsappia commented 3 years ago

@chonnymon here you go ;)

Since we are using the lite version of raspbian, some extra packages need to be installed: sudo apt install xorg sudo apt-get install lightdm sudo apt-get install x11-xserver-utils

raspi-config sudo raspi-config Console Autologin Display Option -> Screen Blanking -> Off if you want to avoid the screen turning black after a few seconds.

.bash_profile In .bash_profile added the following (if the file is not htere, you must create it): `

!/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:

cd /home/pi/fork/retro-ipod-spotify-client/frontend/ sudo -H -u pi python3 spotifypod.py >> spotifypod.log & sudo /home/pi/fork/retro-ipod-spotify-client/clickwheel/click &

Make sure that the paths are ok with your setup!!

in sudo nano /etc/xdg/openbox/environment I set all the variables needed to run spotifypod.py ( SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET,SPOTIPY_REDIRECT_URI)

export SPOTIPY_CLIENT_ID='your_SPOTIPY_CLIENT_ID' export SPOTIPY_CLIENT_SECRET='your_SPOTIPY_CLIENT_SECRET' export SPOTIPY_REDIRECT_URI='your_SPOTIPY_REDIRECT_URI'

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 eceute refresh.devices. This will make the boot up way slower! but I will synchronize every single time you switch on :). If you dont run at least once refresh_data() no playlist, artist or anything related with your account will be displayed!

efernan commented 3 years ago

juj/fbcp-ili9341#125

Hi!

@rsappia Great!!! Now is working for me, I had wrong compilation options, thanks!!!

chonnymon commented 3 years ago

@rsappia

Thanks for all your help, managed to get spotifypod.py to autostart but I had to remove the spotifypod.log

I changed

sudo -H -u pi python3 spotifypod.py >> spotifypod.log &

to

sudo -H -u pi python3 spotifypod.py &

It would say spotifypod.log Permission Denied

Following your instructions, it now syncs artists/playlists, etc...

I did quickly try to connect a set of Bluetooth headphones but couldn't get anything to play. I was hoping to get the pi functional before opening up the iPod, should I be able to get something to play from my keyboard? or is it time to gut the iPod

Thanks Again

rsappia commented 3 years ago

@chonnymon I am glad it worked!

For the Bluetooth connection, you need to do some reading here:

https://github.com/bablokb/pi-btaudio

mattkerrison commented 3 years ago

@rsappia I've got the same display as you, got the drivers working and can see the console on the screen. The next part has me pulling my hair out. I configured everything exactly per your post however once I set the .bash_profile commands I see the console load then switch to a black screen, assuming startx but I'm guessing openbox won't run.

Don't suppose you've got any ideas? or if you encountered this issue?

rsappia commented 3 years ago

@mattkerrison are you using the right cmake variables?

Did you check the last merge I did to the knstallation notes?

mattkerrison commented 3 years ago

@rsappia yea I did, If I take out the startx out of the bash profile I get the console displaying fine on the display, it seems to be an issue with openbox I think, I can't see any obvious logs though

rsappia commented 3 years ago

@mattkerrison Are you also sure it is not a screen saver "issue"? at the very beginning, I thought something was running wrong because after a few seconds, the screen would go black... it was the screen saver. I got rid of directly from raspi config..

I also recall configuring the standard output for openbox... let me look for the link and i will forward it

mattkerrison commented 3 years ago

@mattkerrison Are you also sure it is not a screen saver "issue"? at the very beginning, I thought something was running wrong because after a few seconds, the screen would go black... it was the screen saver. I got rid of directly from raspi config..

I also recall configuring the standard output for openbox... let me look for the link and i will forward it

Are you referring to the raspi-config setting 'screen blanking' I did ensure it was off. Interested to hear about the Standard Output for Openbox if you find it

rsappia commented 3 years ago

@mattkerrison this is something I had to do:

Add to

/etc/X11/Xwrapper.config

the line

allowed_users = anybody

mattkerrison commented 3 years ago

@rsappia I'll try that tonight.

Just checking you didn't set anything like hdmi_force_hotplug=1 or anything?

With the openbox/autostart is the first line supposed to omit the &? ie your script above:

cd /home/pi/fork/retro-ipod-spotify-client/frontend/
sudo -H -u pi python3 spotifypod.py >> spotifypod.log &
sudo /home/pi/fork/retro-ipod-spotify-client/clickwheel/click &

Should it be:

cd /home/pi/fork/retro-ipod-spotify-client/frontend/ &
sudo -H -u pi python3 spotifypod.py >> spotifypod.log &
sudo /home/pi/fork/retro-ipod-spotify-client/clickwheel/click &

rsappia commented 3 years ago

@mattkerrison from what I see, you are taking as reference the steps I mentioned when I opened this "issue", this is old! Take a look to the latest read me pushed by @dupontgu ;)

lidense commented 3 years ago

Hi I ordered this screen and just got it but it seems to be big for the case. Did you succeed in fitting it in?

rsappia commented 3 years ago

@lidense I did :) you have to trim the sides so it fits

20210304_153853.jpg

20210304_141048.jpg

tomaculum commented 3 years ago

hey @rsappia, quick question regarding your image above. How did you wire the to the hold switch and how does the pi interface with it? Everything I have found to use such a switch with the pi did require at least two wires

rsappia commented 3 years ago

@tomaculum I connected one pin of the switch to ground (the one on the right) and the other pin directly to a GPIO configured with an internal pullup ;) Doing that way you can save one wire and it looks cleaner.

tomaculum commented 3 years ago

Ok thank you! (: Last thing I want to reuse is the click / buzzer / speaker thing on the left hand side next to the headphone jack. When I solder those wires, I will try to solder to connect the switch as well

nassafellow commented 3 years ago

@paulomurray silly mistake... I was launchig the script like this:

python3 frontend/spotifypod.py

at some point of the execution, the script couldn't find the png files

it was solved by launchig the script directly from the frontend folder.. this wasn't a problem when I was testing in my PC's console :/

Now I am fighting against screen blanking haha, I havent reached the right xset configuration to avoid that.. right after that... clickwheeeel!!!

what does it mean 'launching the script' and what does this following bit mean???? What is line 16????

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() m

toothless07 commented 11 months ago

Thanks for your tip @dupontgu it was just a wrong path in one of my scripts

PSX_20210209_105758.jpg

Next stop, clickwheel!

By the way...Thanks a lot for sharing! This is an awesome project and I am actually glad that there is no complete guide, otherwise it wouldn't be so much fun involved in just doing copy paste :) I am learning a lot!

Hey I got the same display I am not able to get that working. Can you please share information about how you got that display working Much Thanks!

rsappia commented 11 months ago

Thanks for your tip @dupontgu it was just a wrong path in one of my scripts

PSX_20210209_105758.jpg

Next stop, clickwheel!

By the way...Thanks a lot for sharing! This is an awesome project and I am actually glad that there is no complete guide, otherwise it wouldn't be so much fun involved in just doing copy paste :) I am learning a lot!

Hey I got the same display I am not able to get that working. Can you please share information about how you got that display working Much Thanks!

Hi, did you already have a look here?

https://rsflightronics.com/spotifypod

on the "WIRING THE DISPLAY" section

toothless07 commented 11 months ago

Thanks for your tip @dupontgu it was just a wrong path in one of my scripts PSX_20210209_105758.jpg Next stop, clickwheel! By the way...Thanks a lot for sharing! This is an awesome project and I am actually glad that there is no complete guide, otherwise it wouldn't be so much fun involved in just doing copy paste :) I am learning a lot!

Hey I got the same display I am not able to get that working. Can you please share information about how you got that display working Much Thanks!

Hi, did you already have a look here?

https://rsflightronics.com/spotifypod

on the "WIRING THE DISPLAY" section

hmm no. Thanks for the reply Do we need to install any drivers? Also another question. Did you improve on the code by @dupontgu. I see some steps missing. Since you started this 2 years ago, you might have some insights Thanks so much!

rsappia commented 11 months ago

Thanks for your tip @dupontgu it was just a wrong path in one of my scripts PSX_20210209_105758.jpg Next stop, clickwheel! By the way...Thanks a lot for sharing! This is an awesome project and I am actually glad that there is no complete guide, otherwise it wouldn't be so much fun involved in just doing copy paste :) I am learning a lot!

Hey I got the same display I am not able to get that working. Can you please share information about how you got that display working Much Thanks!

Hi, did you already have a look here? https://rsflightronics.com/spotifypod on the "WIRING THE DISPLAY" section

hmm no. Thanks for the reply Do we need to install any drivers? Also another question. Did you improve on the code by @dupontgu. I see some steps missing. Since you started this 2 years ago, you might have some insights Thanks so much!

Go ahead and read that section, I wrote there about the drivers and configuration needed for this specific display. This is one of the parts that i needed to modify in comparison to Guy's build since we are using different dispays. I am not sure about the missing steps that you mentioned, is it software related?