Tuesday 8 May 2018

Ubuntu HDMI extended monitor low resolution solved

It seems that recent versions of Ubuntu (16.04) has a bug in handling extended HDMI monitors. The HDMI monitor has up to 1980x1080 resolution, my laptop has up to 1366x768 resolution. Both screens have native 16:9 ratio.
However, in "mirrored display" mode, I can only select 1024x768 and 800x600 resolution as shown in the image below:


In such mode, my laptop screen has two blank strip on the left and right side. On the HDMI monitor, it shows a squashed screen (1024x768 resolution stretched to 16:9 full screen).

The solution is to use xrandr to list all display modes and add each mode into every monitor, the shell script is as follows:
displays=(`xrandr | grep '^[^ ]' | awk '{print $1}'`)

xrandr | grep "^ " | awk '{print $1}' | grep [0-9]x[0-9] | sort | uniq \
        | while read mode; do
        echo "Adding $mode ..."
        for display in ${displays[*]}; do
                xrandr --addmode $display $mode
        done
done
You just need to run this script before plugging in the HDMI cable.

No comments:

Post a Comment