Using a Bash script to mirror external monitors
Mirror, Mirror
Like many of my colleagues, I use my own laptop to play back presentations at conferences. My Dell Latitude E6430 works perfectly on Ubuntu. However, one critical problem remains: when I connect the device to a projector or a different display, I don't always get the aspect ratio I would prefer. Screen mirroring typically only gives a poor resolution of 1,024x768 pixels, with large black boxes left and right. Unfortunately, my laptop has a 16:9 display with a resolution of 1,600x900 pixels.
Common Denominator
Some research on the topic of screen resolution reveals the root cause: the maximum resolution that my laptop display and the external projector or monitor have in common is 1,024x768 pixels. All higher resolutions are only available on one of the two devices. When mirroring, my Ubuntu system thus automatically chooses the 1,024x768 resolution as the best common option between the two display devices [1].
Because the external monitor typically uses a 16:10 aspect ratio as a normal office display, it only offers 16:10 resolutions via the data display channel (DDC) interface [2]. In addition to its native 16:9 resolution, the laptop display also supports a number of lower resolutions, but many of these resolutions are rarely supported by external displays or projectors.
In many situations, as the speaker, I want the external display or projector to mirror my laptop's screen contents, so I can work on my laptop while letting others watch.
Enter xrandr
Working on my laptop with a resolution of 1,024x768 is not much fun, but luckily, I have another option. The X Server RandR extension (xrandr
) "provides automatic discovery of modes (resolutions, refresh rates, …) [and] the ability to
Buy this article as PDF
(incl. VAT)