Skip to main content

Raspberry Pi Monitor Rotation
Rotate desktop and touchscreen

Prerequisites

In a former blogpost I described, how to rotate screen and touchscreen in Raspberry Pi OS - formerly known as Raspian.

At that time Raspberry Pi OS uses X11 as display engine - but now, Raspberry Pi OS uses Wayland and the Wayland compositor labwc as standard for the display engine, if you install a fresh system.

Since some things has changed.
For my new settings I use the Raspberry Pi Imager software, to flash Raspberry Pi OS (64-bit) for Raspberry Pi 4 to a SD card.

Settings screen rotation

To rotate the screen (desktop) is easy. You only have to add an file named autostart.

nano ~/.config/labwc/autostart

Paste this code

wlr-randr --output HDMI-A-1 --transform 180

save and that's it.

If you use HDMI 2 change HDMI-A-1 to HDMI-A-2.

Possible rotation values are 0, 90, 180 and 270.

Settings touchscreen rotation

For rotating the touchscreen you have to map the output to the used HDMI and edit a second file:

nano ~/.config/labwc/rc.xml

Before editing this file, you need to know the device name of your touchscreen controller.
You get the right device name of your touchscreen controller with this terminal command:

libinput list-devices

In my case the output of this command contains this:

Device:           TouchNetix AXPB011
Kernel:           /dev/input/event7
Group:            3
Seat:             seat0, default
Capabilities:     touch 
Tap-to-click:     n/a
Tap-and-drag:     n/a
Tap drag lock:    n/a
Left-handed:      n/a
Nat.scrolling:    n/a
Middle emulation: n/a
Calibration:      identity matrix
Scroll methods:   none
Click methods:    none
Disable-w-typing: n/a
Disable-w-trackpointing: n/a
Accel profiles:   n/a
Rotation:         n/a

The device name is "TouchNetix AXPB011".

Paste this code with your adjusted device name into the file:

<?xml version="1.0"?>
<openbox_config xmlns="http://openbox.org/3.4/rc">
    <touch deviceName="TouchNetix AXPB011" mapToOutput="HDMI-A-1" mouseEmulation="yes"/>
</openbox_config>

Also change the HDMI to your needs.