This is a workaround script to automatically rotate the touchscreen input to match the screen orientation on devices like the Lenovo Yoga 370 running Kali Linux with GNOME. It listens for display rotation changes and adjusts the touchscreen coordinate mapping accordingly.
Some convertible laptops and tablets do not properly rotate the touchscreen input when the screen orientation changes. This script fixes that by syncing the touchscreen input with the current display rotation.
- Lenovo Yoga 370
- Kali Linux with GNOME desktop environment
It should work on other Linux systems with similar hardware and software configurations.
xinput— to control input devicesxrandr— to query screen orientation- A touchscreen device detected by
xinput(the script automatically detects the Wacom Finger device) - Bash shell (tested with GNU Bash)
-
Clone or download this repository:
git clone https://github.com/USERNAME/autorotate-touchscreen.git cd autorotate-touchscreen -
Make the script Executable:
chmod +x autorotate.sh
-
Run the script, rotate your screen and test if touchscreen works as intended
./autorotate.sh
The script runs in a loop, checking the screen orientation every second and rotating the touchscreen accordingly.
- To autostart the script on GNOME login without showing a terminal window, create a .desktop autostart entry in ~/.config/autostart/ (see the repo Wiki or system documentation).
- simply put the folder autorot@crashlogs in ~/.local/share/gnome-shell/extensions/ if extensions folder is not there, mkdir it
- this far your should have gnome-shell-extensions & gnome-tweaks installed, if not apt install them
- execute
gnome-extensions enable autorot@crashlogs - press ALT+F2, type "r" and "Enter", this will restart GNOME
Detects the current screen orientation (normal, left, right, or inverted) using xrandr.
Automatically detects the touchscreen device ID via xinput.
Sets the touchscreen coordinate transformation matrix to match the detected orientation.
Continuously monitors for orientation changes every second and updates the touchscreen accordingly.
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to open issues or submit pull requests to improve compatibility or add features.
Made with 🧠 & ☕
