ThinkPad X220 Tablet screen rotation script
|Author:||Martin Ueding <email@example.com>|
If you want to use your X220 Tablet as a tablet, you might want to rotate the screen. You can use this script for that and it will ensure that the pen and touch interface know about the rotated screen.
It will also disable the trackpoint (the xinput id is automatically queried) so that the back of the screen does not move your mouse if there is any force on the side of the screen.
Finally, it will start the virtual keyboard (
kvkbd by default) when the
screen is rotated and kill it when the screen is rotated back to normal.
If the screen is already rotated (say left) and you call
left, the screen will be reverted to the normal orientation. That way, you
can use this script as a toggle.
A udev hook is installed as well that picks up the ACPI event when rotating the screen.
The direction can be any of:
Since the Wacom tools and
xrandrhave different names, this program accepts all of them, so that you do not have to learn yet another set of directions.
- Enable verbose output. Can be supplied multiple times for even more verbosity.
- Do not try to be smart. Actually rotate in the direction given even it already is the case.
- Everything went okay.
- User specified a direction that is not known.
The script relies on
xrandr to get the information, so this has to work.
You can create a config file in
which is a simple INI configuration file. The old config can be converted using
thinkpad-scripts-config-migrate script that was introduced in version
4.0. A sample config would look like this:
[rotate] default_rotation = flip [sound] undock_loudness = 0% [screen] relative_position = left-of
You can set the following option:
- Executable file to run after rotation. Default: ~/.config/thinkpad-scripts/hooks/postrotate
- Executable file to run before rotation. Default: ~/.config/thinkpad-scripts/hooks/prerotate
- Default rotation if device is in normal rotation and no arguments are given. Default: right
- Rotate subpixel orientation when rotating the screen. Default: true
- Rotate the subpixel orientation if a second screen is attached. Default: false.
On Ubuntu 15.04, XRandr has a bug which turns the screen black when rotating with no external screen attached.
This is problematic when the rotation is executed from a hardware event hook. Then the screen is physically laying on the keyboard and one cannot do anything. A workaround is to go to another terminal with [Ctrl][Alt][F1] and back to the graphical one with [Ctrl][Alt][F7].
As contributed by Cody Christensen, that can be automated with
chvt. This way the hook will work in a useful way for users with that XRandr bug. However, this program needs superuser privileges. One can use
sudoto allow oneself to call this program without a password entry. Add the following line in a file like
myuser ALL = NOPASSWD: /bin/chvt
myuserwith your username! Then check with
visudo -cwhether the syntax is fine.
thinkpad-scripts can figure out whether this line is implemented by querying
sudo -lfor a list of available commands with higher privileges. If you set this option to
trueand the line is configured, it will call
chvt 6; chvt 7after the rotation and before the hook.
chvtcannot be used, the hook will be disabled by enabling this option. That way you can manually rotate the contents of the display with
thinkpad-rotate, press [Ctrl][Alt][F1] and [Ctrl][Alt][F7] and only then physically rotate the screen. The hook will not fire and rotate back.
- Regular expression to match the
xrandrname for the internal monitor. Default: LVDS-?1|eDP-?1
- Whitespace-delimited list of the enabled hardware triggers to execute
rotation. The available triggers are
acpi1_normal acpi1_rotated acpi2_normal acpi2_rotated
- Regular expression to match Wacom devices against. If your devices do not
Wacom ISD, change this appropriately. Default:
The Unity Launcher on the left side is only shown if you excert pressure with the mouse. That means that you do not only have to put the mouse to the left edge of the screen, but push it beyond that edge. This is not possible to do with touchscreen or the pen, so you need to show the launcher by default.
With this option set to true, the hide mode will be toggled. That way, you have a hidden launcher on normal rotation, and a always-shown launcher with any rotation. Default: false
- Command to start the virtual keyboard. Choices are (among others)
onboard. Default: kvkbd
You can add scripts to be called before and/or after rotation by placing them
at the following paths. The
postrotate hook gets the new rotation
normal) as a command line argument.
The default paths are:
To rotate the screen to the right (and later back again), use:
To specify the direction, you can use:
thinkpad-rotate left thinkpad-rotate right thinkpad-rotate inverted thinkpad-rotate normal
We hope that this collection of scripts is useful to you. If you experience bugs, find the documentation lacking or have a new kind of hardware that we do not yet support, feel free to open an issue on GitHub or write an email to Martin Ueding.