The Problem: Manually Controlling the Keyboard
Have you ever found yourself in a situation where you needed to quickly enable or disable your keyboard on Linux? Maybe you’re using an external keyboard and want to prevent accidental inputs from your laptop’s built-in keyboard. Or perhaps you need to temporarily disable your keyboard for some reason. Doing this manually can be a bit of a hassle.
The Solution: A Simple Bash Script
To solve this problem, I created a simple Bash script that allows you to enable or disable your keyboard with a single command. Here’s how it works:
The script takes one argument: either ‘enable’ or ‘disable’. It then uses xinput
to find the ID of your keyboard (you’ll need to replace “AT Translated Set 2 keyboard” with the name of your keyboard). If the keyboard is found, the script will either enable or disable it based on the provided argument.
Using the Script
To use the script, simply save it to a file (e.g., keyboard.sh
), make it executable with chmod +x keyboard.sh
, and then run it with either ./keyboard.sh enable
or ./keyboard.sh disable
.