remap the caps key

Hi,

I am trying to remap the caps key in the bsmwp dist of manjaro. Sorry I am newbie so struggling to find the right way to do this.

Thanks,
Murtaza

I have tried setxkbmap -option caps:ctrl and setxkbmap -option caps:swapctrl but that doesnt work.

#!/bin/bash
setxkbmap -option caps:none
setxkbmap -option ctrl:nocaps
setxkbmap -option "shift:both_capslock"
xcape -e "Control_L=Super_L|w" &

This remaps caps and uses xcape to assign super+w.

1 Like

I can't check rn but, I think super+w is already mapped. Maybe to hide/show windows features in manjaro-bspwm. So it may conflict or needs to be commented out in sxhkdrc. Also nice quick work!

@murtaza52 double check sxhkdrc for conflicting keys and change 'w' to another key if needed.

Just an example :smiley:

@xircon thanks for the reply.

I am trying to pull it apart to better understand -

Does this map ctrl to caps?
setxkbmap -option ctrl:nocaps

What does this do ?
`setxkbmap -option "shift:both_capslock"

Why do the remapping for super+w, what am I missing here ?

Also where should I include the above settings, so that they effect for all my apps - emacs, terminal etc - xinitrc, .zshenv etc - This is a newbie question !

Just an example.

setxkbmap -option ctrl:nocaps I am an emacs user, it makes caps a control.

I use caps by pressing both shifts.

Why super+w - I use super+w to launch browser by tapping caps. Long press is a control (left).

It is a standalone script, source it from your bspwmrc. e.g.:

source ~/.config/bspwm/mybspwm.sh&

As the last line.

@xircon thanks appreciate your answers.

One last question on super+w.

  1. What do you mean by long press is a control ? Long press of super is a control ? Or long press of super + w is control ? How is that used / useful (sincere question) ?
  2. I use super+w to launch browser by tapping caps Hos does caps become super+w ?

Thanks,
Murtaza

1 long press = hold

2 xcape maps the tap of the key to super+w.

Try it. Install xcape, run the script. In your sxhkdrc add:
Replace "w" with an unused key in sxhkdrc and the script:

super + w
	alacritty -e tmux

Replace the second line with a program you use, restart sxhkd:

pkill -USR1 -x sxhkd

Tap the capslock, program should open.

Open a terminal, press (hold) capslock + c - should generate a control+c.

Another trick I have - turn the space bar into a Hyper modifier, when held.

This gives you a whole new set of keyboard shortcuts. sxhkd accepts hyper as a modifier so it can also be used in other desktops like plasma.

If you are interested, I can share my xmodmap config and talk you through it.

@xircon thanks for sharing the above tricks with me. The long press key trick is cool !

What is a hyper modifier ? Also the above pkill command did not bring the new keybindings into effect. I have to restart the machine for this. Is there a better way ?

Yes I would be thrilled to walk through your xmodmap config file !

Thanks,
Murtaza

Hyper is a modifier like super and alt. Not many (if any) keyboards have it.

Stage 1:

! Unmap capslock
clear Lock

!Make Alt-gr & menu into Home and end
! This is easier on my laptop.
keycode 135 = End
keycode 108 = Home

! Leave mod4 as windows key _only_
clear mod3 
clear mod4 
add mod3 = Hyper_L 
add mod4 = Super_L Super_R

keycode 65 = Hyper_L
keycode any = space

Save to ~/.Xmodmap.

xmodmap ~/.Xmodmap

loads the file. Space bar (when held) is now a modifier - Hyper.

But it no longer works as a spacebar.........

xcape -e Hyper_L=space

Fixes this.
sxhkdrc:

hyper+w
	firefox

Press and hold space + w = launches firefox.

Put it all together:

#!/bin/bash
setxkbmap -option caps:none
setxkbmap -option ctrl:nocaps
setxkbmap -option "shift:both_capslock"
xmodmap ~/.Xmodmap
xcape -e Hyper_L=space &
xcape -e "Control_L=Super_L|w" &

So now tapping space is a space (defined by xcape), holding is hyper (a new modifier).

Hyper key combos can also be defined in emacs as well:

(global-set-key (kbd "H-p")'package-list-packages)

Pulls up the package manager. sxhkd overides emacs, so if defined in sxhkd, emacs will not see it.

1 Like

@xircon thanks for the detailed replies, it was a great help !

Forum kindly sponsored by