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

rules: setxkbmap deals with empty component differently #497

Closed
wismill opened this issue Aug 6, 2024 · 0 comments · Fixed by #499
Closed

rules: setxkbmap deals with empty component differently #497

wismill opened this issue Aug 6, 2024 · 0 comments · Fixed by #499
Labels
bug Indicates an unexpected problem or unintended behavior X11 legacy: compatibility Indicate a need to ensure compatibility with X11
Milestone

Comments

@wismill
Copy link
Member

wismill commented Aug 6, 2024

Consider the following dummy rules file ~/.config/xkb/rules/dummy:

! model		=	keycodes
  *		=	evdev

! model		=	geometry
  *		=       pc(pc104)

! layout	variant	=	symbols
  *		*	=	pc+%l%(v)

! layout[1]	variant[1]	=	symbols
  *		*		=	pc+%l[1]%(v[1])

! layout[2]	variant[2]	=	symbols
  *		*		=	+%l[2]%(v[2]):2

! layout[3]	variant[3]	=	symbols
  *		*		=	+%l[3]%(v[3]):3

! layout[4]	variant[3]	=	symbols
  *		*		=	+%l[4]%(v[4]):4

! model		layout		=	compat
  *		*		=	complete

! model		layout[1]	=	compat
  *		*		=	complete

! model		=	types
  *		=	complete

setxkbmap and xkbcli compile-keymap give different result with layout = a,b:

# Note: for setxkbmap you need a corresponding .lst file.
# e.g. `ln -s /usr/share/X11/xkb/rules/evdev.lst ~/.config/xkb/rules/dummy.lst`

###################
# Without variant #
###################

# No symbol match!
> setxkbmap -print -rules ~/.config/xkb/rules/dummy -layout a,b
xkb_keymap {
        xkb_keycodes  { include "evdev" };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_geometry  { include "pc(pc104)"     };
};

# Not working, “same” as setxkbmap
> ./build/compile-keymap --kccgst --rules dummy --layout a,b

######################
# With empty variant #
######################

# No symbol match!
> setxkbmap -print -rules ~/.config/xkb/rules/dummy -layout a,b -variant ,
xkb_keymap {
        xkb_keycodes  { include "evdev" };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_geometry  { include "pc(pc104)"     };
};

# Working, contrary to setxkbmap!
> ./build/compile-keymap --kccgst --rules dummy --layout a,b --variant ,
xkb_keymap {
  xkb_keycodes { include "evdev" };
  xkb_types { include "complete" };
  xkb_compat { include "complete" };
  xkb_symbols { include "pc+a+b:2" };
};

#################
# With variants #
#################

# Symbol match!
> setxkbmap -print -rules ~/.config/xkb/rules/dummy -layout a,b -variant x,y
xkb_keymap {
        xkb_keycodes  { include "evdev" };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_symbols   { include "pc+a(x)+b(y):2"        };
        xkb_geometry  { include "pc(pc104)"     };
};

# Working, same as setxkbmap
> ./build/compile-keymap --kccgst --rules dummy --layout a,b --variant x,y
xkb_keymap {
  xkb_keycodes { include "evdev" };
  xkb_types { include "complete" };
  xkb_compat { include "complete" };
  xkb_symbols { include "pc+a(x)+b(y):2" };
};

So we somehow match on empty variant --layout x,y --variant ,, but not when variant is missing --layout x,y (or --layout x,y --variant "").

This neither consistent nor behaves as setxkbmap, so this is a bug. Agreed, this does not trigger yet because the current rules of xkeyboard-config have cover missing variant, but I did encounter this bug while working on xkeyboard-config#478.

Actions to take:

  1. Add a test
  2. Fix the bug
  3. Update the rules doc page about the wildcard behavior. I initially thought it matched everything, even missing component, but it does require a component value (here a variant) in order to match.
@wismill wismill added bug Indicates an unexpected problem or unintended behavior X11 legacy: compatibility Indicate a need to ensure compatibility with X11 labels Aug 6, 2024
@wismill wismill added this to the 1.8.0 milestone Aug 6, 2024
@wismill wismill mentioned this issue Nov 29, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior X11 legacy: compatibility Indicate a need to ensure compatibility with X11
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant