Tablet PC - ArchWiki

Jump to content

# Tablet PC

From ArchWiki

This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.

Reason: Bad style. (Discuss in Talk:Tablet PC)

Related articles

- Graphics tablet

This article aggregates information to get Arch Linux working on a tablet PC. The instructions contain information for getting the touch keyboard, stylus, stylus rotation, and screen rotation to work properly on such devices.

## Stylus

Install xf86-input-wacom.

Note

- To configure stylus devices manually (although not recommended), see the Linux Wacom Project Wiki.
- If your keyboard stops working properly in X after installing xf86-input-wacom, comment all unnecessary entries in `/usr/share/X11/xorg.conf.d/70-wacom.conf` and put the resulting file in `/etc/xorg.conf.d/70-wacom.conf`.

## On-screen keyboards

See List of applications/Utilities#On-screen keyboards.

### With GNOME

Depending on your device, the default GNOME screen keyboard will work automatically when you tap on text input fields. If "Tablet Mode" detection is not working on your device (mutter issue), you might want to customize Gnome Settings > Accessibility.

Enabling Screen keyboard will allow it to always display when a text input field becomes focused.

Always Show Accessibility Menu will allow you to manually enable or disable this depending on your needs.

## Rotation

### Screen rotation

The following sections show generic solutions, desktop environments or Wayland compositors may offer configuration options for these, sometimes through a graphical interface.

Tip The kernel parameters are not mutually exclusive and can both be added.

#### TTY

Use the following kernel parameter[1]:

    fbcon=rotate:1

#### Wayland

Use the following kernel parameter, as detailed in Kernel mode setting#Forcing modes:

    video=DSI-1:panel_orientation=right_side_up

#### Xorg

The simplest way is to use xrandr(1) § orientation:

    $ xrandr --orientation left

On some drivers, this messes-up the DPI: the fonts become unreadable. The `xrandr -o` option is quite old. Using xrandr(1) § rotate solves the issue, but we need to specify the `--output` option first:

    $ xrandr --output eDP --rotate left

### Touchscreen and stylus rotation

#### With xinput

You can use xinput to turn the stylus, like you would rotate a touchscreen.

To set the stylus input to portrait mode:

    $ xinput set-prop name_of_stylus_or_touch_screen --type=float "Coordinate Transformation Matrix"  0 -1 1 1 0 0 0 0 1

To return to landscape mode:

    $ xinput set-prop name_of_stylus_or_touch_screen --type=float "Coordinate Transformation Matrix"  0  0 0 0 0 0 0 0 0

If your stylus is only listed as keyboard:

    $ xinput list

    ⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
    ⎜   ↳ SynPS/2 Synaptics TouchPad              	id=14	[slave  pointer  (2)]
    ⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
        ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
        ↳ ELAN0732:00 04F3:272A Pen               	id=11	[slave  keyboard (3)]

Touch the screen with the pen:

    $ xinput list

    ⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
    ⎜   ↳ SynPS/2 Synaptics TouchPad              	id=14	[slave  pointer  (2)]
    ⎜   ↳ ELAN0732:00 04F3:272A Pen Pen (0)       	id=17	[slave  pointer  (2)]
    ⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
        ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
        ↳ ELAN0732:00 04F3:272A Pen               	id=11	[slave  keyboard (3)]

Using the now listed pointer, the commands should work as expected, turning the stylus.

#### With xsetwacom

If not done yet and in analogy to graphics tablet, an approach to get also the inputs of the touch panel rotated is to install the xf86-input-wacom Xorg driver just as suggested above. After doing so there are various commands available how to manipulate and manage the inputs of the touch panel.

To set the stylus input to portrait mode:

    $ xsetwacom set stylus Rotate cw

To return to landscape mode:

    $ xsetwacom set stylus Rotate none

In case the device 'stylus' cannot be found, use:

    $ xsetwacom list devices

to get a list of devices.

For example:

    xsetwacom set "Wacom Co.,Ltd. Pen and multitouch sensor Pen stylus" Rotate cw

Source: https://xournal.sourceforge.net/manual.html

If you still cannot change the rotation, you can try to use xinput.

## Automatic rotation

### With Xorg

A simple Xorg auto-rotate script could be implemented as follows (uses xorg-xinput, xorg-xrandr and monitor-sensor from iio-sensor-proxy):

    ~/bin/2in1screen

    #!/bin/bash

    DEVICE="ILTP7807:00 222A:FFF1"
    DISPLAYNAME="DSI-1"

    monitor-sensor | while read -r line; do
        case "$line" in
            *normal*)
                xrandr --output $DISPLAYNAME --rotate normal
                xinput set-prop "$DEVICE" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
                ;;
            *left-up*)
                xrandr --output $DISPLAYNAME --rotate left
                xinput set-prop "$DEVICE" "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
                ;;
            *right-up*)
                xrandr --output $DISPLAYNAME --rotate right
                xinput set-prop "$DEVICE" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
                ;;
            *bottom-up*)
                xrandr --output $DISPLAYNAME --rotate inverted
                xinput set-prop "$DEVICE" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
                ;;
        esac
    done

Ensure you mark it as executable.

Alternatives using the same principles are rotate.py or 2in1screen.c.

Both will need to be adapted to your actual devices name and/or path.

You can put this in `.xinitrc` before the exec line:

    .xinitrc

    #!/bin/sh
    # xrandr --dpi 180
    xrdb -merge ~/.Xresources
    ~/bin/2in1screen &
    exec wm_name

Note that there are many other rotate scripts on GitHub, including:

- https://github.com/freundTech/surface-tools/tree/master/autorotate
- https://github.com/andrewrembrandt/surface-autorotate2

### With GNOME

See iio-sensor-proxy. Install the iio-sensor-proxy package.

If you want the rotation, but have the problem that GNOME is adjusting your brightness automatically in a bad way, then you can use these commands to disable it.

For current user, which can also be done via power management GUI:

    $ dbus-launch gsettings set org.gnome.settings-daemon.plugins.power ambient-enabled false

For GDM, which cannot be done via GUI, run as the gdm user:

    [gdm]$ dbus-launch gsettings set org.gnome.settings-daemon.plugins.power ambient-enabled false

In the default Wayland mode GNOME screen rotation is broken on some laptops that don't report the screen flip kernel event (`SW_TABLET_MODE`) and so GNOME does not turn on some tablet features: there is a discussion on GitLab. Install the gnome-shell-extension-screen-autorotateAUR extension to always assume tablet mode when there is a touch screen.

Alternatively use the X11 mode, which you can select from the login screen.

### With a KDE module

Note

- From Plasma 5.25+, kded-rotation-gitAUR is not needed for Plasma Wayland Session.
- kded_rotation is in early development stages and is a bit hacky. Use caution.

Install iio-sensor-proxy and kded-rotation-gitAUR, then restart your Plasma session. Screen rotation should now just work.

For automatic touch screen rotation edit `/usr/bin/orientation-helper` script, changing the hardcoded input device name to match the one you have (choose from the output of `xinput list`).

### With rot8

Install rot8-gitAUR and execute `rot8` for Wayland or `rot8 --touchscreen TOUCHSCREEN` for X11. This integrates well with i3 or sway by using `exec rot8`.

To only start rot8 when the tabletmode is enabled, you can use acpid and modify the handler at `/etc/acpi/handler.sh` to execute `rot8` when the tabletmode event is triggered (you can get the correct event by calling `acpi_listen` and trigger the event by flipping your display).

    /etc/acpi/handler.sh

    ...
        video/tabletmode)
            case "$3" in
                0000008A)
                    #echo 'tablet mode'
                    case "$4" in
                        00000001)
                            DISPLAY=:0 rot8 --touchscreen TOUCHSCREEN &
                            logger 'tablet mode enabled'
                            ;;
                        00000000)
                            killall rot8
                            DISPLAY=:0 xrandr --output eDP-1 --rotate normal
                            rmmod wacom
                            modprobe wacom
                            logger 'tablet mode disabled'
                            ;;
                        *)
                            logger "ACPI action undefined: $4"
                            ;;
                    esac
                    ;;
                *)
                    logger "ACPI action undefined: $3"
            esac
            ;;
     ...

rot8 will automatically detect orientation and rotate modern Linux desktop screen and input devices. For additional configuration see [2].

### With Sway

A simple Sway auto-rotate script could be implemented as follows (uses monitor-sensor from iio-sensor-proxy):

    #!/bin/bash
    monitor-sensor | mawk -W interactive '/Accelerometer orientation changed:/ { print $NF; fflush();}' | while read -r line
    do
       case "$line" in
           normal) swaymsg output eDP-1 transform 0 ;;
           bottom-up) swaymsg output eDP-1 transform 180 ;;
           right-up) swaymsg output eDP-1 transform 90 ;;
           left-up) swaymsg output eDP-1 transform 270 ;;
       esac
    done

Ensure you mark it as executable.

### With Hyprland

A simple Hyprland auto-rotate script could be implemented as follows (uses monitor-sensor from iio-sensor-proxy):

    ~/.config/hypr/scripts/auto-rotate.sh

    #!/bin/bash

    TOUCHSCREEN="nvtk0603:00-0603:f001"

    pkill -f "monitor-sensor" 2>/dev/null

    monitor-sensor | while read -r line; do
        case "$line" in
            *"orientation changed: normal"*)
                # Laptop mode (landscape)
                hyprctl keyword monitor "eDP-1,preferred,auto,2,transform,3"
                hyprctl keyword "device[$TOUCHSCREEN]:transform" 3
                ;;
            *"orientation changed: left-up"*)
                # Tablet portrait (rotated left)
                hyprctl keyword monitor "eDP-1,preferred,auto,2,transform,0"
                hyprctl keyword "device[$TOUCHSCREEN]:transform" 0
                ;;
            *"orientation changed: right-up"*)
                # Tablet portrait (rotated right)
                hyprctl keyword monitor "eDP-1,preferred,auto,2,transform,2"
                hyprctl keyword "device[$TOUCHSCREEN]:transform" 2
                ;;
            *"orientation changed: bottom-up"*)
                # Laptop mode flipped
                hyprctl keyword monitor "eDP-1,preferred,auto,2,transform,1"
                hyprctl keyword "device[$TOUCHSCREEN]:transform" 1
                ;;
        esac
    done

Ensure you mark it as executable, and add it to `hyprland.conf` or `execs.conf` as an `exec-once`.

### With Labwc

A simple Labwc auto-rotate script could be implemented as follows (uses wlr-randr, sed, and monitor-sensor from iio-sensor-proxy):

    ~/bin/2in1screen

    #!/bin/bash

    DISPLAYNAME="eDP-1"

    monitor-sensor | while read -r line; do
        case "$line" in
            *normal*)
                wlr-randr --output eDP-1 --transform normal
                sed -i '/<calibrationMatrix>/c\      <calibrationMatrix>1 0 0 0 1 0</calibrationMatrix>' $HOME/.config/labwc/rc.xml
                labwc -r
                ;;
            *left-up*)
                wlr-randr --output eDP-1 --transform 90
                sed -i '/<calibrationMatrix>/c\      <calibrationMatrix>0 -1 1 1 0 0</calibrationMatrix>' $HOME/.config/labwc/rc.xml
                labwc -r
                ;;
            *right-up*)
                wlr-randr --output eDP-1 --transform 270
                sed -i '/<calibrationMatrix>/c\      <calibrationMatrix>0 1 0 -1 0 1</calibrationMatrix>' $HOME/.config/labwc/rc.xml
                labwc -r
                ;;
            *bottom-up*)
                wlr-randr --output eDP-1 --transform 180
                sed -i '/<calibrationMatrix>/c\      <calibrationMatrix>-1 0 1 0 -1 1</calibrationMatrix>' $HOME/.config/labwc/rc.xml
                labwc -r
                ;;
        esac
    done

Ensure you mark it as executable.

Keep in mind that the default calibration matrix should be created in `~/.config/labwc/rc.xml`, as this script assumes it exists.

    ~/.config/labwc/rc.xml

    <labwc_config>
      <libinput>
        <device>
          <calibrationMatrix>1 0 0 0 1 0</calibrationMatrix>
        </device>
      </libinput>
    </labwc_config>

## Tablet mode

You can use linuxflip-gitAUR or detect-tablet-mode-gitAUR to configure laptop and tablet modes (e.g. enable/disable keyboard/touchpad/trackpoint, start/kill on-screen keyboard etc.)

If no sensor is detected, it can be manually triggered using tablet-modeAUR.

## Desktop Environments / Window Managers

### i3

Using a tiling window manager like i3 makes a lot of sense for a tablet, where screen space is limited. While that may seem unintuitive at first – think about it: Android, iOS and Windows 10's tablet mode all use tiling window managers. Thus, i3 is an excellent window managers for tablets running Arch. The problem is that i3 is designed to be used with a keyboard, without a mouse, so there are no touch controls built in. For the most part, users will need to build their own, though touch gestures (see #Tips and tricks) or by adding touch button controls to a status bar or panel. Users of the polybar status bar can try i3touchmenu.

### Xfce

Xfce works fine on tablets. However, when xfce-screensaver locks, there is no way to show an on-screen keyboard by default. One can be enabled by going to `Settings > Screensaver > Lock Screen` and enabling the `On Screen Keyboard` option. You will also need to add the command required to display your keyboard of choice. For example, using onboard enter this command: `onboard -e`

## Tips and tricks

### Easystroke

Easystroke is a gesture recognition application, recognizing gestures by a variety of input devices, to include pen stylus, mouse, and touch. Gestures can be used to launch programs, enter text, emulate buttons and keys, and scroll. Easystroke is available in the AUR: easystroke-gitAUR.

Note

Easystroke is now unmaintained, the author recommand mouse-actions instead mouse-actions-cli-binAUR and mouse-actions-gui-binAUR.

### Check pen battery

See: Laptop#Battery state

#### Launch CellWriter under pen

One useful application of Easystroke is to use it to launch CellWriter right below your mouse pointer.

This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.

Reason: Script dump, in-code comments (Discuss in Talk:Tablet PC)
Note This script requires the xdotool package, which is not installed by default.

    #!/bin/bash
    # Original author: mr_deimos (ubuntuforums.org). February 14, 2010
    # Many bugs fixed and improvements made by Ben Wong.  October 20, 2010

    # This script toggles the cellwriter letter recognizer window.
    # If a cellwriter window is visible, it will be hidden.
    # If cellwriter is not already running, this will create a new process.
    # If coordinates are specified, the window pops up at those coordinates.
    # If coordinates are not specified, the window is toggled, but not moved.

    # Implementation Note: this script is trickier than it should be
    # because cellwriter does two stupid things. First, it has no
    # --get-state option, so we can't tell if it is hidden or not. Second,
    # both the notification area applet and the actual program window have
    # the same window name in X, which means we can't simply use xwininfo
    # to find out if it is showing or not.
    #
    # (Of course, we wouldn't have to be doing this crazy script at all,
    # if cellwriter had a --toggle-window option to toggle showing the
    # keyboard, but that's another rant...)
    #
    # To work around the problem, we'll assume that if the window we got
    # information about from xwininfo is smaller than 100 pixels wide, it
    # must be an icon in the notification area. This may be the wrong
    # assumption, but, oh well...

    if [[ "$1" == "-v" || "$1" == "--verbose" ]]; then
        verbose=echo
        shift
    else
        verbose=:
    fi

    if [[ "$1" && -z "$2"  ||  "$1" == "-h"  ||  "$1" == "--help" ]] ; then
        cat >&2 <<EOF
    $(basename $0): Toggle showing the cellwriter window, optionally moving it."

    Usage:  $(basename $0) [x y]"
    	Where x and y are the desired position of the cellwriter window."
    	If x and y are omitted, the window is not moved."
    EOF
        exit 1
    fi

    if [[ "$1" && "$2" ]]; then
        x=$[$1-20]			# Offset slightly so cursor will be in window
        y=$[$2-30]
        [ $x -lt 0 ] && x=0		# Minimum value is zero
        [ $y -lt 0 ] && y=0
    fi

    if ! xwininfo -root >/dev/null; then
        echo "$(basename $0): Error: Could not connect to your X server." >&2
        exit 1
    fi

    # Try to obtain CellWriter's window id.
    # We can't use "xwininfo -name" b/c that might find the notification icon.
    OLDIFS="$IFS"
    IFS=$'\n'
    for line in $(xwininfo -root -tree | grep CellWriter); do
        line=0x${line#*0x}		# Just to get rid of white space before 0x.
        $verbose -en "Checking: $line\t"
        if [[ $line =~ (0x[A-Fa-f0-9]+).*\)\ *([0-9]+)x([0-9]+) ]]; then
    	id=${BASH_REMATCH[1]}
    	width=${BASH_REMATCH[2]}
    	height=${BASH_REMATCH[3]}
    	if [[ $width -gt 100 ]]; then
    	    $verbose "looks good."
    	    CW_WIN_ID=$id
    	    break;
    	else
    	    $verbose "too small, ignoring."
    	fi
        else
    	echo "BUG: The xwininfo regular expression in $0 is broken." >&2
        fi
    done
    IFS="$OLDIFS"

    #Check if Cellwriter's window is visible
    if [ "$CW_WIN_ID" ] ; then
        CW_MAP_STATE=`xwininfo -id "$CW_WIN_ID"|grep "Map State"|cut -f 2 -d :`
    else
        $verbose "Can't find cellwriter window, checking for a running process..."
        if ! pgrep -x cellwriter >& /dev/null; then
    	$verbose "No cellwriter process running, starting a new one."
    	if [[ "$x" && "$y" ]]; then
    	    cellwriter --show-window --window-x=$x --window-y=$y &
    	else
    	    cellwriter --show-window &
    	fi
    	exit 0
        else
    	$verbose "Found a process, so the window has not been created yet."
    	$verbose "Pretending the window is UnMapped."
    	CW_MAP_STATE=IsUnMapped
        fi
    fi

    $verbose "Map state: $CW_MAP_STATE"

    case "$CW_MAP_STATE" in

        *IsViewable*)		# Window is currently visible.
    	$verbose "hiding window"
    	cellwriter --hide-window &
    	;;

        *IsUnMapped*)		# Window is currently hidden or non-existent.
    	if [[ "$x" && "$y" && "$CW_WIN_ID" ]]; then
    	    $verbose "moving window to $x $y"
    	    xdotool windowmove $CW_WIN_ID $x $y
    	fi
    	$verbose "showing window"
    	cellwriter --show-window &    # In bg in case cw is not already running
    	;;

        *) 				# This will never happen...
    	echo "BUG: cellwriter is neither viewable nor unmapped" >&2
    	echo "BUG: ...which means this script, $0, is buggy." >&2
    	exit 1
    	;;
    esac

    exit 0

Save the script as cellwriter.sh in either `/usr/local/bin/` or `$HOME/bin`, and make it executable.

Then create a gesture in Easystroke tied to the following command:

    cellwriter.sh $EASYSTROKE_X1 $EASYSTROKE_Y1

When you launch it (using the gesture you created), it will open right under your pen.

#### Gestures for the Alphabet

You can also use Easystroke to make gestures for the entire alphabet, replacing much of the need for CellWriter. To avoid having to make separate gestures for the upper-case letters, you can use the following script to activate the shift key.

Note This script requires the xautomation package, which is not installed by default.

    #!/bin/bash
    if [ -f /tmp/shift ]
    then
      xte "keydown Shift_L" "key $1" "keyup Shift_L"
      rm -f /tmp/shift
    else
      xte "key $1"
    fi

Save the script as keypress.sh in either `/usr/local/bin/` or `$HOME/bin`, and make it executable.

Then create a gesture in Easystroke tied to the following command:

    touch /tmp/shift

This will activate the shift key. To activate the letter keys, tie your gestures to the following command:

    keypress.sh $LETTER

Replace `$LETTER` with the letter in the alphabet in question.

So, when you want to enter an upper-case letter, use your gesture for the shift key followed by the letter. If you want a lower-case letter, simply use your gesture for the letter.

### Xournal & Xournal++

#### Xournal

Xournal is an application for notetaking, sketching, and keeping a journal using a stylus. Xournal aims to provide superior graphical quality (subpixel resolution) and overall functionality.

You can also extend the functionality of xournalAUR with patches, to enable things such as autosaving documents and inserting images. See SourceForge for links to all the available patches. To apply a patch, see Patching packages.

#### Xournal++

Xournal++ (xournalpp) is the successor to Xournal that is currently in development. If you want a newer version Xournal, then you could try this. It is currently stable with little to no bugs that causes crashes.

### GDM

You can also use CellWriter with GDM. First open `/etc/gdm/Init/Default` as root with a text editor. Then near the bottom of the file, add the lines in bold as shown:

    fi
    cellwriter --keyboard-only &
    exit 0

You can add `--window-x` and `--window-y` to adjust the position of CellWriter accordingly. For example:

    cellwriter --keyboard-only --window-x=512 --window-y=768 &

Note You can only use CellWriter with a Plain style GDM.

To start a fully fledged CellWriter instance within the user session, you might want to terminate the instance started with the keyboard-only switch within the gdm context. Add something such as `killall cellwriter` to your newly created file `/etc/gdm/PostLogin/Default`.

Note This works in a single-user setup, if you have a multi-user setup, you might want to develop and post your more elaborate solution.

### LightDM

Configuring LightDM to use Onboard for touchscreen login and unlocking is likely the simplest option (and stable) to provide onscreen keyboard login (when using the default GTK greeter).

Ensure onboard and lightdm-gtk-greeter-settings are installed and run `lightdm-gtk-greeter-settings` to configure onboard to start.

Specifiying `onboard -t Droid -l Phone` configures the Droid theme and sets the Phone layout.

### Touchegg

Touchegg is a multitouch gesture recognizer. It can recongize up to five finger gestures (tap, drag, pinch, rotate...).

## Troubleshooting

### Wacom Drivers

These commands are useful in troubleshooting:

    wacdump -f tpc /dev/ttyS0
    xidump -l
    xidump -u stylus

If xidump shows that your tablets max resolution is the same as screen resolution, then your wacom driver has rescaled your wacom coordinates to the X server's resolution. To fix this, try recompiling your linuxwacom driver with:

    ./configure --disable-quirk-tablet-rescale

### Screen Rotation support

Some video drivers do not support rotation. To check if your driver supports rotation, check the output of `xrandr` for the list orientations:

    normal left inverted right

Category:

- Tablet PCs

Hidden category:

- Pages or sections flagged with Template:Style

Tablet PC
Add topic