Last active
November 24, 2024 22:44
-
-
Save Alynva/2c5cbdd79c429630020be6ba3a530a1b to your computer and use it in GitHub Desktop.
Raspberry HDMI auto detect and update resolution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# sudo nano /etc/udev/rules.d/99-hdmi-hotplug.rules | |
# ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1", RUN+="/usr/local/bin/hdmi_hotplug.sh" | |
# sudo udevadm control --reload-rules | |
logger "Display changed." | |
export DISPLAY=:0 | |
status=$(xrandr | grep 'HDMI-1' | awk '{print $2}') | |
logger "C: $status" | |
if [ "$status" == "connected" ]; then | |
export DISPLAY=:0 | |
# Run xrandr to reconfigure the display | |
xrandr --output HDMI-1 --auto 2>&1 | logger | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment