Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map a key to a specific real mod ONLY for the currently active layout #511

Closed
valkalon opened this issue Sep 20, 2024 · 7 comments · Fixed by #519
Closed

Map a key to a specific real mod ONLY for the currently active layout #511

valkalon opened this issue Sep 20, 2024 · 7 comments · Fixed by #519

Comments

@valkalon
Copy link

valkalon commented Sep 20, 2024

Hi I'm on Ubuntu 22.04 Wayland,learning how to create my personal keyboard layout.
I have a question on a behavior that I don't understand.
I have 2 active layouts : French and "personal".

I want to map <LALT> to mod3 in the personal layout ONLY (do not impact other layouts).

I have tested these options but none of them match the need:

case 1 : key <LALT> { ISO_Level5_Shift };
it applies to all layouts. Not good.

case 2: key <LALT> { F23 };
I use a compat interpret statement to map F23 to Mod3.
Here it works but the ubuntu terminal writes a tilde every time <LALT> is pushed due to not recognizing the F23 keysym.

case 3: LALT to NoSymbol (suprising result)

key <LALT> {
        symbols[Group1]=[ NoSymbol ],
        actions[Group1]=[SetMods(modifiers=Mod3)]
};

Suprising for me the behavior of LALT on the french layout is disabled, as shown by xkbcomp $DISPLAY :

key <LALT> {
//      type[group1]= "TWO_LEVEL",
        type[group2]= "ONE_LEVEL",
   
        symbols[Group1]= [           Alt_L,          Meta_L ],
        actions[Group1]= [ NoAction(), NoAction() ],
        symbols[Group2]= [        NoSymbol ],
        actions[Group2]= [ SetMods(modifiers=Mod3) ]
};

Case 3 would be the best solution but I don't understand why it disables the action in the french layout.

Would you have a solution please?

@wismill
Copy link
Member

wismill commented Sep 20, 2024

Could you dump the whole keymaps and add case 1 here, then add the diff between the remaining cases, so we have all data to check this?

See: xkbcli compile-keymap.

@valkalon
Copy link
Author

I did the dump and investigated but the result does not show what happens to me.

xkbcli compile-keymap gives the output for one layout but the problem appears when input-sources are merged on Ubuntu (french defined as group 1 and "personal" defined as group 2).

I have found a workaround for my need in the meantime using kmonad so I'm good. I don't want to waste your time on this, I close the issue.
Thank you!

@wismill
Copy link
Member

wismill commented Sep 20, 2024

xkbcli compile-keymap gives the output for one layout but the problem appears when input-sources are merged on Ubuntu (french defined as group 1 and "personal" defined as group 2).

You can pass 2 layouts by separating them with a comma, e.g.:

xkbcli compile-keymap --layout fr,custom

@valkalon
Copy link
Author

valkalon commented Sep 20, 2024

I did it. The problem was coming from me. I was messing up the compat files.
Case 1 solved thank you!

About case 3 though I'm wondering what's happening.
Defining symbol/action inline in the symbol file deactivates the actions for the same key in other groups.
This happens with any keysym.
(I'm aware inlining is not recommended by the documentation at xkbcommon.org)

For the sake of example:
rules: evdev
compat: complete
types: complete

image

and the output from :

xkbcli compile-keymap --include /home/gm/.config/xkb --include-defaults --layout fr,mod8 > keymap_kbd.log

keymap_xkb.log

image

Am I doing something wrong?

@valkalon valkalon reopened this Sep 20, 2024
@wismill
Copy link
Member

wismill commented Sep 20, 2024

I get the same result with setxkbmap | xkbcomp. I think what happens here is that explicit actions is a characteristic of the whole key, not just the key’s group. So by setting explicitly in one group you actually set it explicitly in every group, but your group 1 does have explicit action, thus the NoAction() and no use of interpret entries. Will have to check that again though.

You should probably use modmap None { … }; to get rid of the modifier mapping on <LALT> and keep the ISO_Level5_Shift. Check modifier bindings.

@wismill
Copy link
Member

wismill commented Sep 30, 2024

This is actually part of the XKB protocol: “Explicit Keyboard Mapping Components](https://www.x.org/releases/current/doc/kbproto/xkbproto.html#Explicit_Keyboard_Mapping_Components)”.

But I think we should actually set a flag per group and use it to check whether to apply interprets or not to each group.

@valkalon
Copy link
Author

Ok I see.
indeed a flag would make sense. As a newcomer, the "per group" apply of interprets was my initial assumption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants