1

I'd like to run a bash script when I press caps lock in KDE5. I had this working just fine in KDE4. I can easily assign Caps Lock as the trigger to a command in system settings -> shortcuts -> custom shortcuts, but it simply doesn't work.

There are some options in system settings -> input devices -> keyboard -> advanced under "Caps lock key behaviour", but they're all pretty specific such as using caps as an additional modifier key. Disabling also actually disables it completely, rather than just disabling the caps functionality, which is a problem with this approach.

Is there a workaround to properly remap caps?

1 Answer 1

3

Not the most optimal solution, but mapping caps lock to another key, such as 'F22', with xmodmap allows KDE's custom shortcuts to capture caps lock. Then disable the caps functionality:

Add to ~/.Xmodmap:

! May need the following line. On ubuntu this seems to cause an error.
! remove Lock = Caps_Lock
keycode 66 = F22
clear Lock

(Run xmodmap ~/.Xmodmap to parse immediately, rather than relog)

Not sure if both lock lines are needed, but I've spent long enough on this already.


Using setxkbmap works too, but doesn't have the convenience of .Xmodmap. I've tried throwing it in ~/.bash_profile, although this doesn't seem to work there. I suspect because KDE jumps in and re-enables caps lock after its run.

setxkbmap -option ctrl:nocaps
xmodmap -e "keycode 66 = F22"
1
  • First remove Lock line wasn't need for me and actually caused an error. But still works one removed! +1 Jun 7, 2017 at 4:19

You must log in to answer this question.

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