45 lines
1.2 KiB
Python
Executable File
45 lines
1.2 KiB
Python
Executable File
#!/usr/bin/env -S python3 -u
|
|
|
|
import sys
|
|
import os
|
|
|
|
|
|
def ignore_sighup():
|
|
"""
|
|
Ignore hangup signal (that is thrown when launching from systemd?).
|
|
Taken from https://stackoverflow.com/questions/57205271/how-to-display-pygame-framebuffer-using-systemd-service
|
|
"""
|
|
import signal
|
|
|
|
def handler(signum, frame):
|
|
pass
|
|
|
|
signal.signal(signal.SIGHUP, handler)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
# Change directory to the directory of the program launching the script (usually this script "OPEN-GAME").
|
|
if "--go-to-dir" in sys.argv:
|
|
os.chdir(os.path.dirname(sys.argv[0]))
|
|
|
|
# Use the KMS video driver. This works for newer versions of Raspberry Pi with the KMS overlay
|
|
# enabled, SDL 2, and Pygame 2.
|
|
if "--kms" in sys.argv:
|
|
os.putenv("SDL_VIDEODRIVER", "kmsdrm")
|
|
|
|
# Use the framebuffer display. This only works with Pygame 1.9.6 (and SDL 1.2).
|
|
if "--fb" in sys.argv:
|
|
os.putenv("SDL_VIDEODRIVER", "fbcon")
|
|
os.putenv("SDL_FBDEV", "/dev/fb0")
|
|
|
|
# Ignore hangup signal. This may be necessary when launching from systemd.
|
|
if "--ignore-hangup" in sys.argv:
|
|
ignore_sighup()
|
|
|
|
# Launch
|
|
from bitfit.Bitfit import Bitfit
|
|
Bitfit().run()
|
|
|
|
# LocalWords: kmsdrm fbcon fb LocalWords
|