You are not logged in.
I have a ThinkPad T431s laptop. I use .Xmodmap to swap the Caps Lock and Control keys. I have the following lines in my .Xmodmap
! Swap Caps_Lock and Control_L
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L Control_R
and my .xinitrc contains
# if it exists, use .Xmodmap
if [ -s ~/.Xmodmap ]; then
xmodmap ~/.Xmodmap
fi
This works perfectly with the built-in laptop keyboard.
When I plug in a USB keyboard, the keymap does not apply to the new hotplugged keyboard. It continues to apply to the built-in keyboard. This appears to be the same as this 5 year old bug.
A simple workaround is to run
xmodmap ~/.Xmodmap
after plugging in the new keyboard. However, this only works if I type the command on the USB keyboard. I do not understand why this is true. I read the xmodmap man page and tried some Google searches, but could not find information describing how xmodmap interacts with multiple keyboards.
Typing this command each time is not a satisfactory workaround to me. But when I plug in my USB keyboard I am always attaching an additional monitor too. I use autorandr to manage display profiles. I have autorandr bound to a key on my built-in keyboard because I sometimes attach an external monitor without attaching an external keyboard. autorandr executes a script called "postswitch" after a mode switch has taken place. I have put "xmodmap ~/.Xmodmap" in the postswitch script and confirmed that it is being executed.
I see same behavior executing autorandr as xmodmap, which is that if I type
autorandr --change
on my laptop keyboard the keymap doesn't not apply to the USB keyboard. If I type the command on the USB keyboard then the keymap does apply.
One possible workaround is binding autorandr to a key on my USB keyboard. That's likely what I'll fall back to if needed, but I'd really like to understand the behavior of xmodmap!
Last edited by wesphys (2013-11-05 05:26:00)
Offline
The wiki does say that it is not recommended to use xmodmap except for the simplest of tasks. Have you tried any of the recommended alternatives?
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
The wiki does say that it is not recommended to use xmodmap except for the simplest of tasks. Have you tried any of the recommended alternatives?
No. I can look into it though. It seemed to me that swapping two keys was the simplest task.
Offline
cfr wrote:The wiki does say that it is not recommended to use xmodmap except for the simplest of tasks. Have you tried any of the recommended alternatives?
No. I can look into it though. It seemed to me that swapping two keys was the simplest task.
Yes. But maybe "swapping two keys for all keyboards, present and future" isn't! Note I've no idea if this will help - just I happened to read this yesterday re. xmodmap and so it seemed it might be worth experimenting with the "sophisticated" alternatives.
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
wesphys wrote:cfr wrote:The wiki does say that it is not recommended to use xmodmap except for the simplest of tasks. Have you tried any of the recommended alternatives?
No. I can look into it though. It seemed to me that swapping two keys was the simplest task.
Yes. But maybe "swapping two keys for all keyboards, present and future" isn't! Note I've no idea if this will help - just I happened to read this yesterday re. xmodmap and so it seemed it might be worth experimenting with the "sophisticated" alternatives.
Yes, I didn't mean to sound dismissive or anything. I will try this and report back. Thanks!
Offline
The wiki does say that it is not recommended to use xmodmap except for the simplest of tasks. Have you tried any of the recommended alternatives?
I switched to using
setxkbmap -option ctrl:swapcaps
in both my .xinitrc and my "postswitch" script.
When I plug in the the USB keyboard, the keymap is still wrong. But the keymap is now fixed independent of which keyboard I trigger autorandr from. Thanks!
Offline