Skip to content

A Python script that rotates and calibrates the ThinkPad X201 Tablet display with xrandr and xsetwacom in Linux Mint Cinnamon 19.

License

Notifications You must be signed in to change notification settings

bashsudo/x201-tablet-rotate-driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

x201-tablet-rotate-driver

A Python script that rotates and calibrates the ThinkPad X201 Tablet display with xrandr and xsetwacom in Linux Mint Cinnamon 19.

Demo

Rotating Right (Portrait) python3 driver.py -d -1
Rotating Left (Landscape) python3 driver.py -d 1
Rotating Left (Portrait) python3 driver.py -d 1
Automatic Calibration After Any Rotation GIF: after each rotation, the display is calibrated to where the movement of the cursor is accurate and consistent.

Setup and Use

Command Line

Since it supports command-line arguments, the script can be used manually in the terminal.

To rotate the display 90 degrees counter-clockwise to the "left," run:

python3 driver.py -d 1

...which is the same as running the script without any arguments:

python3 driver.py

To rotate the display 90 degrees clockwise to the "right," run:

python3 driver.py -d -1

Widget

It is much more ideal and efficient to execute the command through a touchscreen-friendly widget:

In my particular setup, I used two "Command Launcher" widgets: one to rotate clockwise, another to rotate counterclockwise. Command-executing widgets should be available in many other desktop environments such as XFCE, KDE, or MATE, to name a few.
To configure the widgets in Cinnamon, simply right click one and click on "Configure..."
At a minimum, update the "command" field of the left and right widgets:
LEFT python3 PATH -d 1
RIGHT python3 PATH -d -1
...where "PATH" is the ABSOLUTE path to the driver.py file (relative paths are not recommended here). The script does NOT need to be ran as root. You may also optionally adjust the widget icon, keyboard shortcut, notification, etc.

Rationale and Motivation for the Project

Reason #1: Calibration Completely Broken in Linux Mint

At first, writing a script like this was not necessary: the built-in tablet calibration in Linux Mint Cinnamon 19 worked perfectly... until it didn't.

For context, the ThinkPad X201 Tablet is a 2-in-1 laptop with a Wacom-based display that supports a stylus and touchscreen. Normally when rotating the display, it is expected that the calibration that you set with the Linux Mint utility will remain consistent, no matter the orientation, no matter how much you rotate the display: the cursor would go where your stylus and fingers went.

However, some update had broken this functionality: the calibrations set with the utility will no longer stay whenever the display is rotated. The stylus and touchscreen was not off by a mere few pixels; the cursor would be stuck in a corner of the screen and the display was effectively unusuable.

Reason #2: Forced to Rotate with Keyboard Shortcuts

Another issue unrelated to the calibration was how the display also did not rotate when you physically moved the device around; you needed to tell the system to rotate the display in software as a keyboard shortcut.

This is not entirely at the fault of Linux Mint as the device does not have sensors to detect its orientation automatically, but it would be nice if I was not limited to rotating the screen by hitting a physical button; I wanted an on-screen button or widget that was much more flexible and customizable.

Making the Project

The project was meant to solve both issues with a simple Python script.

As a Python file, the screen could be rotated with a keyboard shortcut, widget, from the terminal, anything that could run shell commands (a lot of things can).

Furthermore, the Python script could perform many actions in one go: the screen could be rotated and then the script could re-calibrate the screen after the rotation, thus solving the aforementioned calibration issue.

About

A Python script that rotates and calibrates the ThinkPad X201 Tablet display with xrandr and xsetwacom in Linux Mint Cinnamon 19.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages