2

When I plug an external keyboard into my laptop (which runs Xubuntu 18.04), I have to run xmodmap ~/.Xmodmap to apply the changes to the second keyboard also. This bothers me.

Here is my .Xmodmap:

! change CapsLock to Escape
clear Lock
keycode 0x42 = Escape

This is supposed to make Caps Lock work like Escape, and works well for the attached keyboard. But when I plug in my USB keyboard in the live system, its Caps Lock does not act like Escape, but still like Caps Lock. I have to run xmodmap ~/.Xmodmap again, to also change the Caps Lock key of the USB keyboard.

If the USB keyboard is plugged in at boot time, there is no problem.

Is there a way to do this automatically, when a keyboard is plugged in?

4
  • It might be possible with udev. May 29, 2019 at 15:35
  • @red_trumpet so when you connect your externel keyboard..the physical kyes and its functions are same? Even though you have swapped Caps Lock and Esc?? do you want solution for this swapping case or really need to run a command when external keyboard is plugged in? What is your Ubuntu Version?
    – PRATAP
    May 29, 2019 at 16:16
  • @PRATAP I added more information to the question. May 30, 2019 at 18:53
  • in that case temporarily remove .Xmodmap file reboot and run this command gsettings set org.gnome.desktop.input-sources xkb-options "['caps:escape']" and then attach your external keyboard
    – PRATAP
    May 30, 2019 at 19:01

0

You must log in to answer this question.

Browse other questions tagged .