The Handshake Failure
When you plug a new monitor into your Ubuntu machine, or when you switch inputs via a KVM (Keyboard, Video, Mouse) switch, Ubuntu relies on a background service (often Xrandr acting on EDID data) to communicate with the display. It attempts to automatically detect the monitor’s preferred, native resolution and adjust your desktop to match. However, if you are using an older monitor, a faulty HDMI cable, or a complex multi-monitor setup with capture cards, this automatic handshake can fail spectacularly. Ubuntu might automatically adjust your resolution to a blurry 800×600, or force a refresh rate that causes the screen to go completely black, rendering the system unusable.
Locking the Display Configuration
To ensure your desktop always remains perfectly crisp and stop Ubuntu from automatically adjusting the display resolution when it detects a hardware change, you must define a static configuration using Xrandr.
You need to force a specific resolution rather than letting the system guess. Open a terminal window (Ctrl+Alt+T). First, identify your connected displays by typing xrandr and pressing Enter. Note the name of your active output (e.g., `HDMI-1` or `DP-2`). Next, you must generate a Modeline for your desired resolution (e.g., 1080p at 60Hz). Type cvt 1920 1080 60 and copy the output after the word “Modeline”. Now, add this new mode to xrandr by typing xrandr --newmode [paste your modeline here]. Then, assign that mode to your specific output: xrandr --addmode HDMI-1 "1920x1080_60.00". Finally, force the output to use it: xrandr --output HDMI-1 --mode "1920x1080_60.00". To make this permanent so Ubuntu never auto-adjusts on boot, you must add these commands to a startup script like `.xprofile` in your home directory.