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

Posted: July 12, 2016. At: 11:21 AM. This was 1 year ago. Post ID: 9416
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

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