I found a solution. Thanks for your help @AastaLLL.
It looks like it was my service
script that was the issue. I added XAUTHORITY
and DISPLAY
and it works great now. ExecStartPre
was also added just to delay the start of the script but wasn’t the reason for it working.
Working code looks like this:
[Unit]
Description=Execute this on boot
After=multi-user.target
[Service]
Environment=XAUTHORITY=/home/ag72/.Xauthority
Environment=DISPLAY=:0
ExecStartPre=/bin/sleep 10
ExecStart=/usr/bin/python3 /home/ag72/Startup/startup_detection_script.py
[Install]
WantedBy=multi-user.target