Run startup script only if no HDMI?
Posted: Thu Dec 18, 2014 8:53 pm
What I would like to do is set up Raspbian so that it does the following:
* If a HDMI monitor (of whatever size or type) is plugged in, boot completely normally.
* If no HDMI monitor is plugged in, boot normally at first, but instead of simply waiting for a user to log in, run a specific script.
The initial use case will be a card / OS set up such that it boots and functions normally when attached to a screen (and presumably keyboard); but if booted with no screen, runs a script that calls a python program that displays an unattended holiday light show on the (presumed) attached Unicorn HAT.
Optionally, I'd like to be able to detect the presence of specific HATs, and run a different script based on whether certain ones are installed; and optionally shut down cleanly if neither a HDMI monitor nor any supported "kiosk" HATs are detected. Another interesting variant might include detection of a keyboard, to set up a third boot state: with-monitor-without-keyboard going into a slideshow, for instance.
I'm generally familiar with Linux and shell scripting, but I'm not clear on how to read the state of the Raspberry Pi monitor detection from a shell script, or where the best place for "do this last" / kiosk style scripts are in the Raspbian boot hierarchy.
For the optional / expansion idea, while I've skimmed some of the HAT info and understand that they have an ID EEPROM, it's not clear what the "stock" method of querying from user-land (shell script, python program, etc.) whether a HAT is present at all, and if so which one is attached.
* If a HDMI monitor (of whatever size or type) is plugged in, boot completely normally.
* If no HDMI monitor is plugged in, boot normally at first, but instead of simply waiting for a user to log in, run a specific script.
The initial use case will be a card / OS set up such that it boots and functions normally when attached to a screen (and presumably keyboard); but if booted with no screen, runs a script that calls a python program that displays an unattended holiday light show on the (presumed) attached Unicorn HAT.
Optionally, I'd like to be able to detect the presence of specific HATs, and run a different script based on whether certain ones are installed; and optionally shut down cleanly if neither a HDMI monitor nor any supported "kiosk" HATs are detected. Another interesting variant might include detection of a keyboard, to set up a third boot state: with-monitor-without-keyboard going into a slideshow, for instance.
I'm generally familiar with Linux and shell scripting, but I'm not clear on how to read the state of the Raspberry Pi monitor detection from a shell script, or where the best place for "do this last" / kiosk style scripts are in the Raspbian boot hierarchy.
For the optional / expansion idea, while I've skimmed some of the HAT info and understand that they have an ID EEPROM, it's not clear what the "stock" method of querying from user-land (shell script, python program, etc.) whether a HAT is present at all, and if so which one is attached.