I have Pi Zero running Raspbian Buster Lite, there's no display attached. It runs a python program at startup (crontab @reboot entry), something like this:
@reboot sudo su username /home/username/launcher.sh >> /home/username/crontab.log 2>&1
I have to initialize pygame display, because I need to process the Sound object end events. Without initializing the display, the events are not triggered.
The code breaks at this line, with error "pygame.error: Unable to open a console terminal"
os.putenv('SDL_VIDEODRIVER', 'dummy')
pygame.display.init() # error at this line
My code used to work in the previous Raspbian (Stretch) version. I have experimented with all kinds of drivers, added/removed pygame.display.set_mode((1, 1))
, but no luck.
I am aware of the other posts that tackle with the same question, but I have exhausted all those approaches - changing the driver to fbcon, skipping the set_mode line, etc. The only thing that works is running the program as root:
@reboot /home/username/launcher.sh >> /home/username/crontab.log 2>&1
But it's a bad idea, from the security perspective. I'd rather run it as unpriviliged user.
Is there a new kind of hack to get it past the display.init()
?