Replies: 2 comments 6 replies
-
CC @mahkoh as an XKB expert |
Beta Was this translation helpful? Give feedback.
-
First of all: interesting concept, without getting to much into the details of the DSL (I'm not fully qualified for this anyway) it would be a very useful addition to XKB.
How much of this is a tooling issue? Can we write a tool take your
AIUI the proposal the transformations are read-only and apply immediately to the keymap on compilation. Which means you could use a builder pattern for an API so that you create a tenative keymap, apply transformations via API, then build the final keymap that xkbcommon currently gives you: struct xkb_keymap_builder * builder = xkb_keymap_builder_new_from_names(ctx, names, flags);
// set symbols[3] = at where key = <AD01>
xkb_keymap_builder_transform_set_symbol(builder, "<AD01>", XK_Q, 3);
// copy <LCTL> into <CAPS>; // clone
xkb_keymap_builder_transform_duplicate_into(builder, "<LCTL>", "<CAPS>");
struct xkb_keymap *keymap = xkb_keymap_builder_build(builder); This would be backwards compatible. Advantage (and disadvantage, depending on the POV) of such an API would also be that you could offload the transformations to an external project which means you don't have to figure out the DSL immediately. So instead of using libxbkcommon directly you use libmykeyboard which has an API that eventually gives you libxbkcommon context and you plug that into the existing holes. DSL style commentsI'm not a fan of "do this .... with that" because it's harder to filter/find what you're looking for, a better approach is "with that .... do this", i.e. the difference between those two:
once you have configuration you're more likely to search for a specific key than "symbols on third level" having that first helps finding what you're looking for. Looking at the other examples: gut feeling tells me before too long users will want to specify the layout as string, so:
Big fan of @mahkoh's suggestion to use e.g. Regarding fwiw, under permutation I understand: give me all combinations of the inputs (see e.g. functools). It might have other meanings but I'm not sure what this example would do (and couldn't be done with a |
Beta Was this translation helpful? Give feedback.
-
This a request of comments (RFC) about an evolution of XKB and the
libxkbcommon
library; see this introduction for further details.Abstract
Add a new type of XKB configuration files, transformations, in order to simplify customization of keymaps:
Sample of the new syntax:
Motivation
There are some use cases that are poorly supported in current XKB:
The limitation is that the XKB format can only set key symbols explicitly and has no generic way to swap/copy keys/levels.
Furthermore, there is always a tension between XKB options and desktop environments (DE) shortcuts. Indeed, the set of options proposed by
xkeyboard-config
is limited and some features are just not supported by XKB, so DE have to deal with 2 interfaces to rebind keys: XKB and their own shortcut handling. DE could produce their own XKB files, but the current API does not give access to some key properties, such as: key type, actions, modifier map, etc. This is a deliberate design choice. Besides, this would require a deep understanding of XKB and creating a XKB keymap generator, which should not be necessary for simple tasks such as “swap two keys”.Finally, keymap components, include mechanism and rules are not always easy to grasp. It can be easier to modify a keymap once its KcCGST components are assembled, i.e. without dealing directly with KcCGST components dependencies.
Rationale
We propose to add a new kind of configuration files, transformations, in order to enable the following modifications of KcCGST components:
“Transformations” are not a new keymap component, but rather just a new keymap section (syntax only). They contribute to the keymap compilation but are not encoded in the compiled keymap.
Rules are extended with a new target component (RHS):
transforms
.Specification
Introduction of the
xkb_transforms
keymap sectionxkb_keymap
is extended with thexkb_transforms
section.The corresponding files are located in the directory
transforms
of the XKB file hierarchy.Grammar
(partial)
TODO: syntax & semantics
Note that contrary to the other sections, the section declaration is optional in
transforms
files, i.e. the following two syntaxes are equivalent. However they cannot be mixed.Compilation stage
Keymap transformations are applied just before computing the derived keymap fields.
Edge cases
Extension of rules files with
transforms
target sectionRules grammar is updated as follow:
Default transformations
There is a special
transforms
file,default
, that is always included first, if present.Examples
xkb_transforms
sectionRMLVO base config:
evdev
pc105
us,de
(none)
(none)
Rules
Backwards Compatibility
xkb_transforms
keymap section or the newtransforms
rules target section.In order to maintain compatibility in XKB files, one may extend the system configuration by adding an extra include path and proceed in the same way than user-configuration, e.g. with
evdev
:EXTRA/XKB/PATH/rules/evdev
: starts with!include evdev
, then adds rules with= transforms
.EXTRA/XKB/PATH/rules/evdev.xml
: adds options that require transformations files.Rejected Ideas
xkb_keymap
is read-only and we would like to preserve that property. We could still clone the keymap and modify it within an internal API, but things get complicated once reaching the derived field step.symbols
section, we could not make transformation across groups in such file. It seems also clearer to have dedicated section type for this RFC’s use cases.Open Issues
@bluetech @whot
Beta Was this translation helpful? Give feedback.
All reactions