Check Lock Keys state from command-line
I want to check Lock keys (i.e Caps Lock, Num Lock, Scroll Lock etc.) state (On/Off) from command-line. How do I check state via terminal command?
Solution 1:
simply run:
xset q
From man xset
:
q The q option gives you information on the current settings.
In the top section of the output, you will find your information, looking like:
Keyboard Control:
auto repeat: on key click percent: 0 LED mask: 00000003
XKB indicators:
00: Caps Lock: on 01: Num Lock: on 02: Scroll Lock: off
03: Compose: off 04: Kana: off 05: Sleep: off
06: Suspend: off 07: Mute: off 08: Misc: off
09: Mail: off 10: Charging: off 11: Shift Lock: off
12: Group 2: off 13: Mouse Keys: off
You can use grep
to get specific result as follows:
$ xset -q | grep Caps
00: Caps Lock: off 01: Num Lock: on 02: Scroll Lock: off