How to use the command xinput (with examples)

How to use the command xinput (with examples)

The xinput command is a versatile tool that allows users to list available input devices, query information about a device, and change input device settings. It is particularly useful when dealing with input devices such as keyboards, mice, and touchpads. In this article, we will explore several common use cases of the xinput command and provide examples for each one.

Use case 1: List all input devices

Code:

xinput list

Motivation: The motivation for using this example is to get a comprehensive list of all input devices connected to the system. It can be helpful when troubleshooting input device issues or when users want to have an overview of their available input devices.

Explanation: The xinput list command lists all the input devices connected to the system. It provides information such as the device ID, device name, and any additional properties associated with each device.

Example output:

⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                id=12   [slave  pointer  (2)]
⎜   ↳ TPPS/2 IBM TrackPoint                     id=13   [slave  pointer  (2)]
⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Sleep Button                              id=8    [slave  keyboard (3)]
    ↳ Integrated Camera: Integrated C           amera    id=9    [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=10   [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                    id=14   [slave  keyboard (3)]

Use case 2: Disable an input

Code:

xinput disable <id>

Motivation: Disabling an input can be useful when troubleshooting or when users want to temporarily disable a certain input device, such as a touchpad or a specific keyboard.

Explanation: The xinput disable command disables the input device with the specified ID. The ID can be obtained from the list of input devices using the xinput list command.

Example output: (no output will be displayed if the input device is successfully disabled)

Use case 3: Enable an input

Code:

xinput enable <id>

Motivation: Enabling an input device that has been previously disabled can be useful when the user wants to re-enable the device after troubleshooting or upon their request.

Explanation: The xinput enable command enables the input device with the specified ID. The ID can be obtained from the list of input devices using the xinput list command.

Example output: (no output will be displayed if the input device is successfully enabled)

Use case 4: Disconnect an input from its master

Code:

xinput float <id>

Motivation: Disconnecting an input device from its master can be necessary in certain situations. For example, if a touchpad is behaving erratically due to interference from another input device, floating the touchpad can help isolate the issue.

Explanation: The xinput float command disconnects the input device with the specified ID from its master device. The ID can be obtained from the list of input devices using the xinput list command.

Example output: (no output will be displayed if the input device is successfully floated)

Use case 5: Reattach an input as slave to a master

Code:

xinput reattach <id> <master_id>

Motivation: Reattaching an input device as a slave to a specific master can be helpful when users want to establish a specific relationship between input devices, such as connecting a keyboard as a slave to a touchpad.

Explanation: The xinput reattach command reattaches the input device with the specified ID as a slave to the master input device with the specified master ID. The IDs can be obtained from the list of input devices using the xinput list command.

Example output: (no output will be displayed if the input device is successfully reattached)

Use case 6: List settings of an input device

Code:

xinput list-props <id>

Motivation: Listing the settings of an input device can be useful when users want to explore the available settings and configure them according to their needs.

Explanation: The xinput list-props command lists the properties and settings of the input device with the specified ID. The ID can be obtained from the list of input devices using the xinput list command.

Example output:

Device 'SynPS/2 Synaptics TouchPad':
        Device Enabled (151):   1
        Coordinate Transformation Matrix (153): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
        Device Accel Profile (282):     1
        Device Accel Constant Deceleration (283):       2.500000
        Device Accel Adaptive Deceleration (284):       1.000000
        Device Accel Velocity Scaling (285):    12.500000

Use case 7: Change a setting of an input device

Code:

xinput set-prop <id> <setting_id> <value>

Motivation: Changing the settings of an input device can allow users to customize the behavior and performance of their input devices, such as adjusting the sensitivity or acceleration of a touchpad or mouse.

Explanation: The xinput set-prop command changes the value of the specified setting for the input device with the specified ID. The ID and setting ID can be obtained from the list of input devices and their properties using the xinput list and xinput list-props commands, respectively.

Example output: (no output will be displayed if the setting is successfully changed)

Conclusion:

The xinput command provides a wide range of functionalities for managing and configuring input devices in a Linux system. With the ability to list devices, enable or disable inputs, attach or detach devices to masters, and modify device settings, users have the necessary tools to fine-tune their input devices according to their preferences and troubleshoot any issues that may arise. Understanding the various use cases and examples demonstrated in this article should empower users to make the most out of the xinput command and optimize their input device experience.

Related Posts

How to use the command killall (with examples)

How to use the command killall (with examples)

The command killall is used to send a kill signal to all instances of a process by name.

Read More
How to use the command 'yarn-why' (with examples)

How to use the command 'yarn-why' (with examples)

The command ‘yarn-why’ is a useful tool for identifying why a specific Yarn package has been installed in your project.

Read More
How to use the command 'jdeps' (with examples)

How to use the command 'jdeps' (with examples)

jdeps is a command-line tool provided by Oracle that analyzes the dependencies of Java class files or Java archive (JAR) files.

Read More