Skip to content →

Fixing Automatic Screen Rotation in Ubuntu

With some laptops like the one in the Getting XIDU PhilBook Max to Play Nice with Linux tutorial there can be a different offset than the standard one that is expected.

In order to avoid staring at the screen at right angles (to the detriment of both your neck and sense of orientation) we must make some changes to the configuration file for the orientation matrix in the distro. In the previous tutorial we covered a situation where the distribution didn’t support automatic rotation out of the box; now we cover a situation where the distro does support it.

First lets fix the head cranking temporarily so we can keep our sanity as we do this

xrandr -o normal

Thanks to Kristian on Stack Overflow we know how to get the relevant model information

First lets get the driver name

sudo udevadm info -n /dev/iio:device0

Now lets get the vendor and product name

sudo dmidecode | grep Manufacturer
sudo dmidecode | grep Product

Now we need to replace the information into the brackets in the string below

sensor:modalias:acpi:[driver name]*:dmi:*:svn[Manufacturer]:pn[Product Name]:*
 ACCEL_MOUNT_MATRIX=0, 1, 0; 1, 0, 0; 0, 0, 1

In our case we end up with (using * as wildcards)

 ACCEL_MOUNT_MATRIX=0, 1, 0; 1, 0, 0; 0, 0, 1

Where ACCEL_MOUNT_MATRIX is the transformation matrix that represents our orientation

Now lets add it to the end of our list of display rotations, to do this we follow the instructions at the top of the /usr/lib/udev/hwdb.d/60-sensor.hwdb

sudo nano /etc/udev/hwdb.d/61-sensor.hwdb

Paste in the string you made above, and save

Now we need to get the system to adopt the changes

sudo systemd-hwdb update
sudo udevadm trigger -v -p DEVNAME=/dev/iio:device0
sudo service iio-sensor-proxy restart

Now the screen should rotate as expected!

Remember this was for my specific laptop and the transformation matrix necessary for your laptop may be different.

Published in Uncategorized


Leave a Reply

Your email address will not be published. Required fields are marked *