Is there any way to detect if a Pi is running headless on raspbian. I would like to automatically start tightvncserver if headless.
I developed a script which detects when using RCA video and starts tightvncserver.
I still have trouble getting this to run on startup.
I put the following into rc.local
This runs (before the login prompt) and I can see the output on the console when I have a display (hdmi) attached, but it does not seem to work with no display.
I can run the script if I login via ssh
# If running headless (i.e. default RCA video) start tightvncserver
if /opt/vc/bin/tvservice -s | grep 'NTSC\|PAL'; then
echo $(hostname) is running Headless
/usr/bin/tightvncserver
else
echo $(hostname) is running hdmi
fi