How to toggle the caps lock key with the command line in Linux Mint.

The Caps Lock key may be toggled using the command line. The xdotool utility will do this for you. Firstly, install the utility.

jason@jason-virtual-machine ~ $ sudo apt install xdotool

Then toggle the caps lock key with this command.

jason@jason-virtual-machine ~ $ xdotool key Caps_Lock

Run this command again to turn caps lock off.

On a Virtual Terminal, this will also work.

setleds -D +caps

This will turn caps back off.

setleds -D -caps

This line of code will turn off caps lock in Linux when used in the terminal.

python -c 'from ctypes import *; X11 = cdll.LoadLibrary(""); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XCloseDisplay(display)'

This is three ways to toggle caps lock with the command line. Are there any more? I will have to investigate this and see.

No comments have been made. Use this form to start the conversation :)

Leave a Reply