plork
September 15, 2021, 9:28am
1
Hey, so I like to remap my CapsLock to Control, which I do by running setxkbmap -option ctrl:nocaps
.
I have this in my ~/.Xkbmap
to set it at boot time.
-option ctrl:nocaps
The problem is that this setting keeps resetting at seemingly random times, so I’ll be typing away and suddenly CapsLock becomes CapsLock again.
It’s doing my head in! Any ideas what could be resetting thing and how I can make this permanent?
Welcome to the forum!
For me, setxkbmap
resets whenever I connect/disconnect a device. (speaker, keyboard)
I don’t know a way to make it permanent; what I did was to add a keyboard shortcut in my i3wm config to run the command again in background.
kjw
September 15, 2021, 10:25am
3
xircon
September 15, 2021, 10:34am
4
Which DE? Am at work, but you can use xmodmap to do this or tweaks on Gnome.
plork
September 15, 2021, 10:35am
5
Well that is very interesting! I was just about to say that this isn’t a result of connecting/disconnecting a device since it happens too regularly.
However, just to check I ran udevadm monitor
, and indeed it does seem that just wiggling the usb cable is actually disconnecting and reconnecting the USB device! Plugging into a different USB port doesn’t do this.
So at least this will save my sanity for a lot of the time!
It would still be nice, but not totally essential now, to work out how to make this setting more permanent though.
1 Like
xircon
September 15, 2021, 11:00am
7
If it can wait, I will share my .Xmodmap when I get home (19:00 UK time).
plork
September 15, 2021, 11:10am
8
Yeah that would be awesome, thanks. I did try using .Xmodmap before to fix this, but couldn’t get it working. Would be very interested to see what you did!
xircon
September 15, 2021, 5:35pm
9
clear lock
clear control
add control = Caps_Lock Control_L Control_R
keycode 66 = Control_L Caps_Lock NoSymbol NoSymbol
I currently use interception tools, and this article helped me:
Note: Check out my original article from 2013 about the rationale behind this remapping. Recently I’ve switched back from macOS to GNU/Linux, as my primary development environment, and I found out that my old article on remapping Enter to Control was...
It seems to be more resilient to bombing out. This is my config:
TIMING:
TAP_MILLISEC: 250
DOUBLE_TAP_MILLISEC: 150
MAPPINGS:
# Hold enter for left control
# - KEY: KEY_ENTER
# TAP: KEY_ENTER
# HOLD: KEY_LEFTCTRL
# Tap = super+w
- KEY: KEY_LEFTALT
TAP: [KEY_LEFTMETA,KEY_W,]
HOLD: KEY_LEFTALT
# Tap = super+t
- KEY: KEY_LEFTCTRL
TAP: [KEY_LEFTMETA,KEY_T,]
HOLD: KEY_LEFTCTRL
# Tap = Escape
- KEY: KEY_RIGHTCTRL
TAP: [ KEY_LEFTMETA, KEY_E, ]
HOLD: KEY_RIGHTCTRL
# Tap = Escape
- KEY: KEY_CAPSLOCK
TAP: KEY_ESC
HOLD: KEY_LEFTCTRL
# Tap is left/right bracket
# - KEY: KEY_LEFTSHIFT
# TAP: [ KEY_LEFTCTRL, KEY_SPACE, ]
# HOLD: KEY_LEFTSHIFT
- KEY: KEY_RIGHTSHIFT
TAP: [ KEY_LEFTALT, KEY_LEFT, ]
HOLD: KEY_RIGHTSHIFT
# Tap super for rofi:
# - KEY: KEY_LEFTMETA
# TAP: [ KEY_LEFTMETA, KEY_D, ]
# HOLD: KEY_LEFTMETA
- KEY: KEY_MENU
TAP: KEY_HOME
HOLD: KEY_HOME
The relevant bit is:
# Tap = Escape
- KEY: KEY_CAPSLOCK
TAP: KEY_ESC
HOLD: KEY_LEFTCTRL
1 Like
plork
September 16, 2021, 8:45pm
10
Awesome thanks. I’ll have a look at interception, I didn’t know about those before, but they look really powerful!