Repository navigation
Auto On HDMI Port
M Hightower edited this page Jan 5, 2019
·
4 revisions
- When a display is not plugged into the HDMI port at boot time, the video defaults to the analog connector.
- While the HDMI Hot Plug option works, unless you set all the geometry values, you do not get a good match for physical screen size to virtual size as well as a good font size.
- If you use the
hdmi_force_hotplug=1option in the/boot/config.txtfile and you setup good geometry values in the/boot/config.txtfile. Then, when you use a different monitor, everything is broken again. - It is assumed, that the Monitor connected to the HDMI works well when it is already connected at the time your Raspberry Pi is powered up and boots. The port properties present at this time, are the ones that are captured for later use.
- When using this script do not set the
hdmi_force_hotplug=1option in the/boot/config.txtfile. - For each monitor you may use with the Raspberry Pi, connect it and boot once. This gives the script the opportunity to capture/cache working geometry settings for each monitor.
Uses tvservice and fbset to make the HDMI port ready for use. Relies on a USB keyboard or mouse being plugged in, to trigger a udev rules entry, that will launch the script to turn on and set up the HDMI port. The script runs for 30 seconds, waiting for a monitor to be plugged into the HDMI port, before timing out.
cd /usr/local/bin
sudo wget https://github.com/mhightower83/misc-bash/raw/master/auto-on-hdmi-port
sudo chmod +x auto-on-hdmi-port
sudo auto-on-hdmi-port --install
Usage for "/usr/home/bin/auto-on-hdmi-port":
sudo auto-on-hdmi-port --install
Installs systemd service to run the command "auto-on-hdmi-port
--update-cache" at boot time. Installs udev rules to run the
command "auto-on-hdmi-port --power-on" when a USB HID device is
connected. eg. Plugging in a USB keyboard or USB mouse.
sudo auto-on-hdmi-port --uninstall
Undo "auto-on-hdmi-port --install".
Next two options are for reference.
auto-on-hdmi-port --power-on [how long to wait in seconds, optional]
This command is used to start the script, to monitor for a display
connected to the HDMI port. When the display is connected, it runs
the programs to set up the HDMI port. This is the command that is
launched via the udev rules RUN command. (must run from root)
auto-on-hdmi-port --update-cache
This command is issued at boot time by the systemd service
auto-on-hdmi-port.service. This script option will capture and record
the geometry of a working display with its device_name value. This
information is stored in the file "/usr/local/etc/displayCache". (must
run from root)
auto-on-hdmi-port --help
Prints this message.
auto-on-hdmi-port --help-dev
Prints help on some deprecated options that were used during development.