A Python script that rotates and calibrates the ThinkPad X201 Tablet display with xrandr and xsetwacom in Linux Mint Cinnamon 19.
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
It is much more ideal and efficient to execute the command through a touchscreen-friendly widget:
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.
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.
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.