I also run a fairly custom system for which I had to solve this exact problem.
I didn't want to do anything complicated, so I "solved" it by adding a small screen detection bash script, which checks whether the screen is up every few seconds, and starts the program only after the screen is up (can be done via ExecStartPre in systemd)
Detecting whether the screen is up could be done in a few ways:
1) You can detect it by looking at. This probably requires disabling hotplug if you've enabled it, and might depend on your screen/monitor and on its settings (whether it's truly off or simply on standby).
2) The rube goldberg way: if your screen gets an IP address, you could ping it (if it gets a fixed IP) or find it by mac address
3) Even uglier: if possible, an ethernet cable between the pi and the screen allows you to simply check whether the ethernet link can be established (with mii-tool or ethtool)
Obviously very far from ideal, but I've been happy with this contraption. Obviously it's very custom - if you intend to move your Pi around it's probably unpractical, in which case please ignore my message![Smile :)]()
I didn't want to do anything complicated, so I "solved" it by adding a small screen detection bash script, which checks whether the screen is up every few seconds, and starts the program only after the screen is up (can be done via ExecStartPre in systemd)
Detecting whether the screen is up could be done in a few ways:
1) You can detect it by looking at
Code:
/sys/class/drm/card*-HDMI-A-1/status2) The rube goldberg way: if your screen gets an IP address, you could ping it (if it gets a fixed IP) or find it by mac address
3) Even uglier: if possible, an ethernet cable between the pi and the screen allows you to simply check whether the ethernet link can be established (with mii-tool or ethtool)
Obviously very far from ideal, but I've been happy with this contraption. Obviously it's very custom - if you intend to move your Pi around it's probably unpractical, in which case please ignore my message
Statistics: Posted by vikmik — Wed Apr 02, 2025 11:21 am