Created
January 14, 2025 01:26
-
-
Save plu5/b0eb53f9af086f2297358c4406a38c24 to your computer and use it in GitHub Desktop.
Linux X toggle keyboard script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # use `xinput list` to check your keyboard name. this one is for laptop internal keyboard | |
| deviceName="AT Translated Set 2" | |
| builtInId=$(xinput list | grep "$deviceName" | sed 's/^.*id=//' | sed 's/\t.*//') | |
| case $1 in | |
| disable) | |
| xinput disable $builtInId | |
| echo "Keyboard '${deviceName}' disabled" | |
| ;; | |
| enable) | |
| xinput enable $builtInId | |
| echo "Keyboard '${deviceName}' enabled" | |
| ;; | |
| *) | |
| echo "Toggle keyboard '${deviceName}' (id ${builtInId})" | |
| echo "Invalid options" | |
| echo "Syntax: $0 enable/disable" | |
| exit | |
| ;; | |
| esac | |
| # if you have an xmodmap config you need to reapply it | |
| xmodmap ~/.Xmodmap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment