You are not logged in.

#1 2019-01-28 20:25:17

lugge
Member
Registered: 2017-03-17
Posts: 38

[SOLVED] xmodmapping has no effect

Hi there, I have set up an .Xmodmap file for setting up the caps lock key as Mod4.
I do this because I want to use caps as mod key in i3.

From my i3 config:

...
set $mod Mod4
...

And this is my .Xmodmap:

[lugge@lugge-VM ~]$ cat .Xmodmap 
remove Lock  =Caps_Lock
clear mod4
add Mod4 = Caps_Lock
[lugge@lugge-VM ~]$ 

This should be working becaue when I load it with xmodmap and check it right after, I can see that the mapping has indeed changed.

[lugge@lugge-VM ~]$ xmodmap
xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3      
mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

[lugge@lugge-VM ~]$ xmodmap .Xmodmap 
[lugge@lugge-VM ~]$ xmodmap
xmodmap:  up to 2 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock      
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3      
mod4        Caps_Lock (0x42)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

[lugge@lugge-VM ~]$ 

So, Caps is mapped to mod4.

However, i3 still recognizes SUPER as mod key, CAPS is ignored.
I execute xmodmap from a terminal inside i3.
Do I have to do this before i3 has started in order to take effect?

Last edited by lugge (2019-01-30 07:10:53)

Offline

#2 2019-01-28 21:23:29

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,686

Re: [SOLVED] xmodmapping has no effect

Likely.
Try "xev -event keyboard", caps lock should register as Super_L press/release and shortcuts along it should "& 0x40" in their state (likely 0x50, 0x10 is for the numlock)
In that case everything works as expected, but isn't received by i3, because the shortcut is registered along the keycode which will still be resolved to 133 before your mapped caps lock.

You can btw. also turn caps lock into an additional super (mod4) key using an xkb rule (caps:super)

Online

#3 2019-01-29 04:24:59

lugge
Member
Registered: 2017-03-17
Posts: 38

Re: [SOLVED] xmodmapping has no effect

Using setxkbmap (executing it from within i3) it is working as expected. CAPS is recognized as mod4.
However, xmodmap is not reflecting this setting:

[lugge@lugge-VM ~]$ setxkbmap -option caps:super
[lugge@lugge-VM ~]$ xmodmap
xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock      
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3      
mod4        Super_L (0x42),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

mod4 should also list CAPS_LOCK. Does xmodmap not show changes made by setxkbmap?

But, I'm still not satisfied.
Why is my first solution (see opening post) not working? I want to understand this issue before proceeding.
As far as I understand, my task should also be possible with xmodmap.

seth wrote:

Try "xev -event keyboard", caps lock should register as Super_L press/release and shortcuts along it should "& 0x40" in their state (likely 0x50, 0x10 is for the numlock)
In that case everything works as expected, but isn't received by i3, because the shortcut is registered along the keycode which will still be resolved to 133 before your mapped caps lock.

I tested as you suggested. xev output when pressing CAPS (after xmodmap .Xmodmap):

KeyRelease event, serial 28, synthetic NO, window 0x3800001,
    root 0x3af, subw 0x3800002, time 444595, (38,40), root:(575,79),
    state 0x2, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

Key is still recognized as Caps_Lock.
How is this possible? Is my .Xmodmap wrong?

Last edited by lugge (2019-01-29 04:39:26)

Offline

#4 2019-01-29 09:19:39

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,686

Re: [SOLVED] xmodmapping has no effect

Sanity check: did you try xev afer xmodmap on top of the xkb rule?
Otherwise try "keycode 66 = Super_L" to map the keycode to super_l

Online

#5 2019-01-30 07:10:34

lugge
Member
Registered: 2017-03-17
Posts: 38

Re: [SOLVED] xmodmapping has no effect

I have read that the use of xmodmap is deprecated and setxkbmap is now the way to go.
With setxkbmap, this is just an one-liner and works like a charm.

Offline

Board footer

Powered by FluxBB