- You have a laptop with a 13" screen and 1920x1080 resolution and a 4K external monitor.
- You run the laptop at 1x scale.
- You run the 4K screen at 2x scale (pixel doubled).
- You’re running elementary OS 5.x (Hera) or elementary OS 6 (Odin)
Which means that text scale should be 1x when the 4K monitor is plugged in but it should be larger than that (at least ~1.5x) to be legible on the laptop’s screen. (Yes, the manufacturer of the laptop chose the wrong resolution for the screen. It should have been QHD (2560 × 1440) or at most QHD+ (3200×1800) so that you could run it confortably pixel doubled.)
Anyway, it’s not and you’ve already bought it (and it’s otherwise an excellent laptop) but you don’t want to change the text scale every time you plug it into and unplug it from your external monitor.
You need to add a udev rule that gets triggered whenever your screen setup changes (fun fact: you listen for the drm event – sigh – the state of things!) and then run a script that sets the
- Configure the
80-personal.rulesscript (see instructions in script) and then place it in
- Configure the
auto-text-scale.shscript (see instructions in script) and save it somewhere. Make sure you set it as executable:
chmod +x auto-text-scale.sh.
- Reload your udev rules:
sudo udevadm control --reload
You can also test your rules (they will not run but it will show you if they would run were this not a test). Again, customise for your own device:
udevadm test --action="change" /devices/pci0000:00/0000:00:02.0/drm/card0