How to Change Mouse and Touchpad Settings Using Xinput in Linux

How to Change Mouse and Touchpad Settings Using Xinput in Linux
Most Linux distributions ship with “libinput” library by default to handle input events on a system. It can process input events on both Wayland and X and can handle a variety of input devices including touchscreen displays and stylus pens.

This article explains changing various options for an input device being handled by the libinput library. To check and configure available options, a command line tool called “xinput” will be used.

Note that this guide works with X display server only. For Wayland, you have to rely on system settings provided by the distribution or use a centralized configuration utility like gsettings.

List Input Devices

Xinput comes pre-installed by default on Ubuntu. If for some reason it is not installed on your system, run the command below to install it:

$ sudo apt install xinput

To list all built-in and external input devices connected to your system, run the command below:

$ xinput --list

You will see some output in terminal like this:

The entry under “Virtual core pointer” (highlighted by red arrows) is a wired USB mouse connected to my system. You will have to use exact name or id shown in the screenshot above to configure mouse or touchpad settings through the xinput command line tool.

Note that in the screenshot above, xinput is showing properties of devices connected to my system. Device names and IDs will be different for your system depending on your hardware configuration and external devices connected via USB, Bluetooth, or wireless receivers.

View Properties of a Connected Device

To see current status and various options active for the device listed above, run a command in the following format:

$ xinput --list-props “id”

For the Dell mouse listed above, the command would be:

$ xinput --list-props 8

There is a limitation with using this command. IDs shown in the terminal output tend to change when you connect a listed device to a different port. As the IDs keep changing, there is always a chance of accidentally changing settings for a different device. To overcome this issue, it is better to use full device name as identifier instead of its id. So for the Dell mouse listed above, the better command would be:

$ xinput --list-props "PixArt Dell MS116 USB Optical Mouse"

The area highlighted below in red rectangle shows current configuration for the device. You can only change options that are shown in the output. Depending on the capabilities of your device, some extra options may be listed while others can be omitted altogether.

Change Properties of a Connected Device

Now that you know how to check the properties of a connected input device, settings for it can be easily changed using some simple commands.

For instance, to enable or disable natural scrolling, you have to run commands in the following format:

$ xinput set-prop "PixArt Dell MS116 USB Optical Mouse" 285 0
$ xinput set-prop "PixArt Dell MS116 USB Optical Mouse" 285 1

“285” is the id for natural scrolling, as shown in the screenshot above. “0” disables natural scrolling while “1” enables it. Once again, using IDs is not a reliable way to change these settings. A better approach is to use the full property identifier.

$ xinput set-prop "PixArt Dell MS116 USB Optical Mouse"
"libinput Natural Scrolling Enabled" 0
$ xinput set-prop "PixArt Dell MS116 USB Optical Mouse"
"libinput Natural Scrolling Enabled" 1

Note that you are not supposed to touch property identifiers having the word “Default” in it. These are reference fallback values and any attempt to change them will result in xinput throwing an error.

To know more about other options and those listed in the terminal output above, visit the following page.

Making the Changes Persistent

The method explained above changes settings for active session only. When you reboot the system, these changes will be gone. To make them persistent, two approaches can be used.

The first method requires you to add these commands to startup applications. You can add as many entries as you want using a nice graphical interface. No root permissions are required to create these entries, plus changing them later is super easy.

To add the command to startup applications, launch “Startup Applications” app from the application launcher. Click on “Add” button to add an entry. Set a description and enter appropriate xinput command as per your needs. Make sure that checkbox is checked once you have saved the entry.

That's it, the xinput command you have entered will run automatically on system startup. I have added a little bit of delay to the command to wait for the session to load properly. For reference, here is the command used below in the screenshot below:

$ sleep 3 && xinput set-prop "PixArt Dell MS116 USB Optical Mouse"
"libinput Natural Scrolling Enabled" 1

The second method requires you to run some commands as root and edit a text file. The advantage of using this method is that you don't have to create separate entries for each option in a GUI and everything just resides in one text file, making it easier to share it between devices.

Run the commands below to create required directory and the conf file:

$ sudo mkdir -p /etc/X11/xorg.conf.d
$ sudo touch /etc/X11/xorg.conf.d/99-libinput.conf

Notice the “99” part in the filename. It indicates the load order of the files that exist in “xorg.conf.d” folder. A file that has the highest number as prefix will be loaded last, overriding any options specified in previous files in case there are duplicates. By specifying “99” or any other number as a prefix, you can ensure that it is loaded after other files.

Open “99-libinput.conf” file with root access in your favorite text editor. Enter the code snippet below after making necessary changes as per your requirements.

Section "InputClass"
Identifier "Dell Mouse"
MatchProduct "PixArt Dell MS116 USB Optical Mouse"
Option "NaturalScrolling" "true"


By correctly specifying “MatchProduct”, you will be able to limit the configuration options to a specific device only. Changes made in the conf file will take effect when you reboot next time. You can add any number of options in the “InputClass” section. A list of various options that can be added to the file is available here.


The method explained above is especially useful when you want to use per device configuration rules. Default system settings interface in GNOME and KDE provide only some of the most commonly used options available for various input devices. To configure advanced options for an input device, you have no choice but to either use “xinput” or create a dedicated configuration file.

Parhaat pelikonsoliemulaattorit Linuxille
Tässä artikkelissa luetellaan suositut pelikonsolin emulointiohjelmistot, jotka ovat saatavana Linuxille. Emulointi on ohjelmistojen yhteensopivuusker...
Best Linux Distros for Gaming in 2021
The Linux operating system has come a long way from its original, simple, server-based look. This OS has immensely improved in recent years and has no...
Kuinka siepata ja suoratoistaa pelisessiosi Linuxissa
Aikaisemmin pelaamista pidettiin vain harrastuksena, mutta ajan myötä pelialalla tapahtui valtava kasvu tekniikan ja pelaajien määrän suhteen. Peliala...