Note: This tool is intended primarily for external or built-in touchscreens that do not have integrated orientation sensors. It manually sets the display rotation and touchscreen calibration matrix.
This Python script offers a reliable terminal interface to automatically rotate the display and persistently calibrate the touchscreen input matrix in Wayland environments. It uses the modern gdctl utility (GNOME libinput for the touchscreen matrix, bypassing deprecated tools like gnome-randr.
The script is strictly intended for use under Wayland (GNOME).
- Python 3
gdctl(Part of GNOME; for persistent display rotation)libinput(for Wayland input management and calibration)- User must be in the
inputgroup (see Installation). sudopermissions for writing udev rules.gnome-terminalorgnome-console(akakgx)
| Distribution Type | Command |
|---|---|
| Debian/Ubuntu | sudo apt-get install python3 libinput-tools |
| Arch | sudo pacman -S python libinput |
| Fedora | sudo dnf install python3 libinput |
To execute libinput operations without needing sudo, add your user to the input group. A re-login is required.
| Distribution Type | Command |
|---|---|
| Debian/Ubuntu | sudo usermod -a -G input YOUR_USERNAME |
| Arch/Fedora | sudo usermod -aG input YOUR_USERNAME |
Clone the repository and run the script:
git clone https://github.com/fraz0815/gptouch-python.git
cd gptouch-python
python3 gptouch.pySimply run python3 gptouch.py.
You can use flags to skip prompts, making it perfect for mapping to keyboard shortcuts or rotation scripts.
-o, --orientation 1: Landscape, 2: Portrait (Right), 3: Portrait (Left), 4: Inverted
--skip-reboot
--skip-gdm-
Detection: Identifies the active monitor via
gdctl showand the touchscreen device path vialibinput. -
Rotation: Uses
gdctl set --transform ...to rotate the visual display. -
Calibration: Uses the correct LIBINPUT_CALIBRATION_MATRIX and writes a udev rule to
/etc/udev/rules.d/99-touchscreen-orientation.rules. -
Hot-Reload:
- Reloads udev rules (
udevadm control --reload). - Rebinds the Driver: Temporarily unbinds and rebinds the touchscreen kernel driver to force it to read the new calibration matrix instantly.
-
GDM Sync:
Checks if
~/.config/monitors.xmlexists and copies it to the system-wide GDM configuration path (e.g.,/var/lib/gdm/.config/or/etc/xdg/depending on GNOME version).
This repository includes a GNOME Shell Extension that adds a convenient drop-down menu to your top panel for quick display and touchscreen rotations with a single click.
We provide an automated script to install and enable the extension on your system.
Open your terminal and navigate to the cloned repository:
cd gptouch-pythonMake the installation script executable:
chmod +x install.shRun the installer:
./install.shImportant (Wayland): GNOME Shell does not allow hot-reloading extensions under Wayland. You must log out and log back in for the changes to take effect.
Once logged back in, the extension will be active and you will see the rotation icon in your top panel!
This project is licensed under the MIT License.