Switch an X Input Device Between Absolute and Relative Mode

Plug in a graphics tablet and the pointer starts jumping about: xsetmode switches a device between absolute and relative coordinates. The command is tiny, but the effect is immediate, and a pointer, tablet or touchscreen can behave very differently the moment it lands.

Allow about ten minutes. You need an X11 session, the exact device name, and the xsetmode command from x11-xserver-utils. These examples use the installed package version 7.7+10build2. They do not need sudo. Run them as the user connected to the X display, with the appropriate display authorisation.

Safety boundary: Changing input mode can make a device awkward or unusable until you change it back. Keep a keyboard-controlled terminal open before testing. Do not use a shared or remote display unless you understand which user's device you are changing.

1. Check the command shape

The installed command accepts exactly two arguments: a device name, then the mode name. It does not list devices, show the current mode, or take a short option for either mode.

$ command -v xsetmode
/usr/bin/xsetmode
$ xsetmode
usage : xsetmode <device name> (ABSOLUTE|RELATIVE)

The usage message and non-zero exit status are expected when the arguments are missing. Check the package version too, if you are documenting a machine-specific procedure:

$ dpkg-query -W -f='\${Package} \${Version}\n' x11-xserver-utils
x11-xserver-utils 7.7+10build2

Checkpoint: The command is installed and this guide's syntax matches the local binary.

2. Obtain the exact X device name

xsetmode needs the device name known to the X Input extension, which is not necessarily the name printed on the hardware. Get it from the X input listing or diagnostic tool your desktop or application already uses. Copy the name exactly, including spaces and punctuation.

For the examples below, replace DEVICE_NAME with that value. The quoted shell variable is deliberate: an X device name commonly contains spaces.

DEVICE_NAME='YOUR EXACT X DEVICE NAME'
printf 'device: %s\n' "$DEVICE_NAME"

Do not guess a name such as mouse or tablet. A wrong name fails outright, but a right-looking name that is not quite right can quietly select a different physical device from the one you intended.

3. Set absolute mode

Absolute mode maps the device straight to positions or coordinates. It commonly suits a graphics tablet or touchscreen-style device, though whether it is right for yours depends on the device and the X driver.

$ xsetmode "$DEVICE_NAME" ABSOLUTE
$ printf 'xsetmode status: %s\n' "$?"
xsetmode status: 0

A status of zero means the X server accepted the request; the command normally prints nothing else on success. Move or use the device in a controlled way and check whether the application sees the behaviour you expect.

This is a live change to the X input device, not a permanent configuration file edit, and it needs no elevated privileges. The mode may be lost when the X server or device restarts, depending on how your session manages input devices.

Checkpoint: If the device now behaves correctly, note the exact command and device name for your session setup. If it behaves badly, keep the terminal focused with the keyboard and move on to the recovery step.

4. Recover with relative mode

Relative mode reports movement as changes from the previous position: the usual model for a conventional mouse or trackball. To undo the absolute-mode example, run the same command with RELATIVE:

$ xsetmode "$DEVICE_NAME" RELATIVE
$ printf 'xsetmode status: %s\n' "$?"
xsetmode status: 0

There is no separate reset command: switching to the other mode is the recovery action. If the pointer is hard to control, use keyboard navigation to reach the terminal. If the X session becomes unusable, log in through another terminal or end the affected session with your normal system procedure, then start a fresh one.

5. Handle the common failures

Capture the status immediately after the command runs, because a later command overwrites the shell's last status:

xsetmode "$DEVICE_NAME" RELATIVE
status=$?
if [ "$status" -eq 0 ]; then
    printf '%s\n' 'Input mode changed'
else
    printf 'xsetmode failed with status %s\n' "$status" >&2
    exit "$status"
fi

If you see the usage line, check that both arguments are present and that the mode is spelled exactly ABSOLUTE or RELATIVE. The manpage documents no other modes or flags.

If the command cannot open the display, check that you are inside the intended X11 session and that DISPLAY and X authorisation are actually available:

$ printf 'DISPLAY=%s\n' "\${DISPLAY-}"
DISPLAY=:0

An empty or wrong DISPLAY is a session problem, not a reason to reach for sudo: running through sudo can strip the X authorisation the command needs. Restore the session environment, or run the command as the logged-in desktop user instead.

If the device name is rejected, go back to the listing tool and copy the full name again. If a status-zero change has no visible effect, the device or its X driver may not support both modes: xsetmode itself warns that the operation is not appropriate for every device type. Do not keep toggling a production device while trying to guess support; make one harmless, reversible change and check the driver documentation instead.

Done means