0

I Have a raspberry pi 4B running using Debian GNU/Linux 12. I created an executable file as GUI. I want to start this GUI before the login window appear and when ever the user close it the login appear again. I just created a service for this prepuce but still getting error. the GUI is starting after the login is attempt . this is my service :

[Unit]
Description=My PyInstaller Executable
Before=graphical.target
After=lightdm.service

[Service]
Type=simple
ExecStartPre=/bin/sleep 30 # Add a delay to ensure X server is fully initialized
ExecStart=/usr/bin/xinit /home/pi/Desktop/NewMain
User=pi
Group=pi
Restart=always
RestartSec=10
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/pi/.Xauthority
WorkingDirectory=/home/pi/Desktop

[Install]
WantedBy=graphical.target

and this is the error:

Dec 06 07:00:40 raspberrypi systemd[1]: Starting My PyInstaller Executable...
Dec 06 07:01:57 raspberrypi systemd[1]: Started My PyInstaller Executable.
Dec 06 07:01:58 raspberrypi NewMain[855]: Invalid MIT-MAGIC-COOKIE-1 keyInvalid MIT-MAGIC-COOKIE-1 keyTraceback (most recent call last):
Dec 06 07:01:59 raspberrypi NewMain[855]: File "NewMain.py", line 326, in <module>
Dec 06 07:01:59 raspberrypi NewMain[855]: File "NewMain.py", line 308, in main
Dec 06 07:01:59 raspberrypi NewMain[855]: File "tkinter/__init__.py", line 2270, in __init__
Dec 06 07:01:59 raspberrypi NewMain[855]: _tkinter.TclError: couldn't connect to display ":0"
Dec 06 07:01:59 raspberrypi NewMain[855]: [855] Failed to execute script 'NewMain' due to unhandled exception!
Dec 06 07:01:59 raspberrypi systemd[1]: myservice.service: Main process exited, code=exited, status=1/FAILURE
Dec 06 07:01:59 raspberrypi systemd[1]: myservice.service: Failed with result 'exit-code'.
Dec 06 07:01:59 raspberrypi systemd[1]: myservice.service: Consumed 1.550s CPU time.
Dec 06 07:02:09 raspberrypi systemd[1]: myservice.service: Scheduled restart job, restart counter is at 1.
1
  • Georges, your question is gibberish... did you look at it after posting? You need to read up on Markdown, and figure out how to format all that "stuff" in the last paragraph. Hint: When you edit your Question, there is a "bar" at the top, and it has a ? on the RHS. Click this ? & explore the "mysteries" of Markdown. (Hint: try a 'Code fence')
    – Seamus
    Dec 12, 2023 at 18:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.