There's a bunch of ways to do this.
On windows, I would just use AutoHotKey.
On a linux distro, setxkbmap
does the trick, but it is not as flexible.
The goal:
- remapping the capslock to control
- remap something else to toggle capslock
- restore default keyboard settings
Until I find a nice hotkey program, setxkbmap
will do.
info xkeyboard-config
This can also be found from info setxkbmap
in the "SEE ALSO" section.
It has a full list of all the options.
Some quick commands to get the job done:
setxkbmap -option ctrl:nocaps
setxkbmap -option ctrl:swapcaps
setxkbmap -option caps:ctrl_modifier
This clears all of the options.
setxkbmap us -option
This option will toggle caps by pressing both shift keys together, and
setxkbmap -option shift:both_capslock
Turn capslock into control, and still have the ability to
setxkbmap -option caps:ctrl_modifier -option shift:both_capslock
Make an alias for quick enable/disable. Can be anything, but this is what I'm using right now:
alias mycaps-on='setxkbmap -option caps:ctrl_modifier -option shift:both_capslock'
alias mycaps-off='setxkbmap us -option'
Now you'll be able to type in the alias command instead of the
verbose setxkbmap
insanity.
mycaps-on
mycaps-off