How to Enable, Disable Keyboard, Mouse and Touch Devices via Terminal

1 min


You can do various quick configuration changes such as to enable, disable devices using Xinput via Terminal in Linux in general. Here’s how.

Xinput is a utility that gives you configuration options to control mouse, keyboard, touchpad, touch screen devices in Linux (applicable for all Linux distributions such as Ubuntu, Fedora). It is part of xorg-xinput package which provides various device services.

How to enable, disable devices using Xinput

Open up the terminal. To list out all the devices connected to your computer run below command. It will list out all devices with their device ID. This device ID is important because you have to pass it as an argument when enabling or disabling any device.

xinput -list

The above command should give you a list of devices with ID – something like this. You can see all the keyboards (in case you have multiple keyboards attached), touchpad, pointing devices are listed with their device ID.

xinput-list
xinput-list

You can easily figure out by name which device they represent.

For example, if I want to disable any device say the touchscreen, simply run:

xinput disable 13

This will immediately disable the touchscreen of a device (as per the above example). And to enable, simply run:

xinput enable 13

Before you use, make sure that you are correctly enabling or disabling based on the device ID. Be extra cautious while enabling or disabling keyboard which might prevent you to type the command while enabling it (although you can use the onscreen keyboard).

Also, note that the device IDs can vary based on your system, and also they might get changed after every reboot if you plug-in any devices. So, careful while using this command in a shell script for automation.

This trick is very handy when you have multiple keyboards, mouse, or touch devices attached to the system. You can then disable or enable as per your need to prevent any accidental use of devices such as a touchpad.

You can do lots of quick configuration with your connected devices including the touch inputs.


We bring the latest tech, software news and stuff that matters. Stay in touch via Telegram, Twitter, YouTube, and Facebook and never miss an update!

Join our Telegram channel and stay informed on the move.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.


Arindam

Creator of debugpoint.com. All time Linux user and open-source supporter. Connect with me via Telegram, Twitter, LinkedIn, or send us an email.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

2 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
2
0
Would love your thoughts, please comment.x
()
x