0

I have a Dell Latitude 7400 laptop running Linux Mint 20.1, with Linux 5.4 and Cinnamon 4.8.6. When I log in, I run this script.

1 #!/bin/sh 2 3 /usr/bin/killall xcape 2>/dev/null 4 /usr/bin/xmodmap -e 'remove Lock = Caps_Lock' 2>/dev/null 5 /usr/bin/setxkbmap -option 'ctrl:nocaps' 6 /usr/bin/xcape 

Lines 4 and 5 turn the Capslock key into a Control key, and xcape (line 6) turns the left Control keys (especially the one that was just the Capslock key) into Escape keys when pressed alone, or a Control key when pressed with other keys. If I have to run the script again, the killall on line 3 ends any previous xcape instances before starting a new one.

I have a Logitech USB headphones + microphone headset, and fairly generic Space Travel brand Bluetooth earbuds. Whenever I plug the headset in, or connect the earbuds to the laptop via Bluetooth, it undoes the entire effect of the script, and the Capslock key is again just a Capslock key. This has happened with Monoprice brand headphones as well, although I no longer have those headphones to test now.

How can I prevent connecting audio peripherals from interfering with the way I have the keyboard set up, or how can I detect when it happens and have the script above run again?

I use vim, and having an Escape key no longer work as an Escape key can be very disruptive.

Thank you.

2
  • First things first, Linux Mint 20.1 is EoL. Please upgrade to a supported release. Commented Jun 12 at 22:32
  • @DavidG answer points to a possible solution through the Udev system Commented Jun 13 at 14:01

1 Answer 1

2

I think what you are seeing is that you have plugged in a new event device (volume buttons?), effectively a new keyboard. The way modern X deals with multiple keyboards is to reconfigure the keyboard every time you switch, which at the very least is when a key is pressed on a different keyboard. This tends to kill the xmodmap effects at the very least.

As for how to stop it? I wish I knew. I've had issues with xmodmap being undone for years.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.