parasurv@webspace ~ $

Blog: {Site updates} {Linux} {Free Software} {Culture} {Health} {Watches collection} Learning: {Emacs Journal} {Linux Wiki} Personal: {Contact} {About me}

Shorts: {Microblog} {Linkblog} Important: {Read} {Watch} {Listen} Other pages: {Old games stuff}

Make Caps Lock Control

I have to say that ever since I switched to Emacs, I haven't used the Caps Lock as a normal key. Since Emacs uses Ctrl as a prominent key in their system, I had to made Caps Lock, my Ctrl key. And it's simple to do, but not in every case.

I had problem with my bluetooth keyboard, since when it turns off automatically to save battery, it also resets some of the keyboard settings, i.e. Caps Lock as Ctrl, which resulted that I had to enable it every time, when my keyboard disconnected.

I used setkbmap for months, then I looked around and found a permanent solution to it. I don't know why I haven't started with this originally, but I am glad I found a solution with Xmodmap.

Switch Caps Lock and Ctrl

The file ~/.Xmodmap is in your HOME directory and hidden (that's the dot in front of the file name). You can also use your ~/.config directory for that, like I do in ~/.config/X11/xmodmap.

In any case, fire up your favorite text editor and open or create the file. Then copy and paste the lines below. In this file, you can comment out lines with the exclamation point:

!
! 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

And disable Caps Lock completely

The solution above swithes the Ctrl key with Caps Lock. If you want to disable Caps Lock altogether, you need to remove the following line:

keysym Control_L = Caps_Lock

Automate

If you are using modern display managers, you don't have to do anything, the system will automically see the ~/.Xmodmap file. If you are using startx via ~/.xinitrc, then you need to add the following line to it:

xmodmap ~/.Xmodmap

Hosted on Neocities and created with Emacs, the world best text editor, operating system. This website doesn't track you. I don't use any javascript or other scripts. I don't store any information about the visitors. It's just pure old fashioned HTML. Some parts of the site is not up-to-date design wise. I may or may not update them in the future. I don't really support mobile stuff, but I bet if you disable the little CSS I have, you can read the site perfectly.