13

I have a Das Keyboard plugged into a ThinkPad running Linux. For some reason, sometimes Ubuntu requires me to re-run xmodmap when I unlock my screen, which swaps my Caps Lock key with Control, as I desire. This happens so often that I usually leave a terminal window open where xmodmap is the last command that I ran, so I can hit and then Enter to re-run the command and fix my keyboard. Unfortunately, sometimes I forget to do this right away, and I don’t notice until I use the Caps Lock key and discover that it has forgotten its mapping to the Control key.

Today was one such day. Unfortunately, I forgot to hit the Caps Lock key again to disable it before running xmodmap (which as described, I do without typing any characters, which would have alerted me to caps lock being on). Now caps lock is enabled and I have no key I can hit to disable it because Caps Lock is already mapped to Control. I tried logging out and back in right away, but apparently that is not “long enough” for Ubuntu to forget my key mapping. (Also, it was hard to log back in because I had to remember to hold the Shift key down while typing my password.) Is there anything I can run from the command line to undo this easily rather than creating a new .xmodmap file that undoes the mappings added by my current one?

0

3 Answers 3

12

You can run the setleds -caps command from within a console. To get to a console, press Ctrl+Alt+F1, and press Ctrl+Alt+F7 to get back to where you were.

Info on this post

1
  • GOT THIS: setleds: Error reading current flags setting. Maybe you are not on the console?: ioctl KDGKBLED: Inappropriate ioctl for device
    – Neinstein
    Commented May 12, 2023 at 8:33
2

I remapped my (utterly useless) Scroll Lock as my new Caps Lock.

!!!
!!! For Dvorak and Qwerty
!!!
remove Lock = Caps_Lock
remove Lock = Scroll_Lock
remove Control = Control_L
keysym Scroll_Lock = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Lock = Scroll_Lock
add Control = Control_L
0

You can copy-paste the following into a terminal (Ctrl-Alt-Del on Ubuntu) to turn it off :

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

(source)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .