0

I want to switch caps lock in i3 at startup I wrote a script and put this code:

setxkbmap -option ctrl:nocaps

But still i get the message:

Mär 28 09:52:20 dave-desktop systemd[1]: myfirst.service: Main process exited, code=exited, status=255/EXCEPTION
Mär 28 09:52:20 dave-desktop test.sh[6068]: Cannot open display "default display"

Anyone any solution?

muru
  • 193,181
  • 53
  • 473
  • 722
David
  • 226
  • 2
  • 12
  • 1
    Does this answer your question? [How to remap keys on a user level both with and without X](https://askubuntu.com/questions/485454/how-to-remap-keys-on-a-user-level-both-with-and-without-x) – vanadium Mar 28 '21 at 09:45

1 Answers1

0

Here is a solution i found using .XModmap:

Put this in ~/.Xmodmap and if you have a similar problem use xev to check out your Keynames.

!
! Swap Caps_Lock and Control_L
!
remove Lock = Caps_Lock
remove Control = Control_L
remove Lock = Control_L
remove Control = Caps_Lock
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L

For further reading:

https://unix.stackexchange.com/questions/107566/how-to-swap-ctrl-and-capslock-using-xmodmap https://medium.com/@retprogramisto/how-to-make-custom-keyboard-map-with-xmodmap-1341a1552d4f

David
  • 226
  • 2
  • 12