Hi all, I’m hoping someone can help me fix a silly mess I’ve made!
I have built a simple Python game using the pygame library that outputs to a monitor connected to the Raspberry Pi via HDMI. The game runs in fullscreen mode.
I have triggered the game to start on boot by opening the following file:
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
and then adding this to the bottom of the file:
@/usr/bin/python /home/pi/game_filepath.py
The problem is that there is an error in the code after the game starts running in fullscreen mode. When I boot up the Pi the opening title screen appears and then the game is stuck. Because the game is running fullscreen there is no way to exit the game and get back to the desktop. If I reboot the Pi it just runs the same script with the same error and gets stuck.
There are two solutions I can think of:
-
Force the Pi to boot to the command line. If there is a way to do this (e.g. by holding down some key combo after switching it on) then hopefully I could navigate to the autostart file and remove the line that triggers the script. Alternatively I could just remove the python script from its folder so that the autostart has nothing to trigger.
-
SSH into the Pi - unfortunately I wasn’t able to get this to work over a remote connection before I triggered the game. I know that SSH is switched on on the Pi because I was able to SSH in when using the same wifi network. The Pi is now connected via a USB modem and I haven’t been able to connect remotely.
The Pi is a 4b (I’m not sure of the other specs as I can’t get into it any more!). Any ideas would be really appreciated.
To make matters worse - the game is actually part of a public exhibition and the organisers have had to shut it down for the day while I try to figure out how to solve the problem remotely…
EDIT: Solved now, here is the solution I ended up using in case anyone is interested.
- Switched Pi on and tapped ctrl+alt+F1 until it booted to the command line
- Navigated to a folder containing a file the script referred to early in the code.
- Renamed the file - this way the code errored out much earlier in the program - before it got to the full screen line.
- Rebooted and was taken to the desktop (because the script crashed before it got to the fullscreen line).
Once at the cli I could have navigated to the autostart file, but because I was talking a non-technical person through the process over the phone I thought this was an easier option.