You are not logged in.
Dear all ![]()
When I use wev to dump key presses, I for Insert" get
[14: wl_keyboard] key: serial: 16863; time: 17568466; key: 118; state: 1 (pressed)
sym: Insert (65379), utf8: ''
[14: wl_keyboard] key: serial: 16864; time: 17568530; key: 118; state: 0 (released)
sym: Insert (65379), utf8: ''where I would like to convert "Insert" or "key: 118" to the format that xkb_options use in Sway config.
E.g. in wev Caps Lock is
[14: wl_keyboard] key: serial: 17362; time: 17688611; key: 66; state: 1 (pressed)
sym: Caps_Lock (65509), utf8: ''where in xkb_options is is "caps"...
What I am trying to accomplish is converting my old xmodmap file
keycode 118 = Delete
keycode 119 = Home
keycode 117 = End
keycode 110 = Prior
keycode 115 = Next
keycode 49 = 0into the Sway config.
Any help in converting the wev format to xkb_option format will be very much appreciated ![]()
Hugs,
Sandra ![]()
Last edited by LittleSandra (2023-03-14 23:34:04)
Offline
You can't - they're totally different things used for different purposes. As noted in your other thread, xkb provides a number of options (listed in the man page) for common key swaps such as caps:escape, caps:none, etc. But these are built in options and are not referring to actual keysyms (Caps_Lock and Insert are keysyms). To change the keysym generated by these keys you'd need to create your own custom layout. There isn't much to this as you can use an existing layout as a base and only specify your changes. For example, on one of my computers I have a "Menu" key that is of no use to me, but could be useful as another modifier (Mod5 in my case). To change the keysym (and modifier state) of this key I created the file ~/.xkb/symbols/us-custom with the following content:
default partial alphanumeric_keys modifier_keys
xkb_symbols "basic" {
include "us"
name[Group1]= "English (US, Custom)";
key <MENU> { [ Hyper_L ] };
modifier_map Mod5 { Hyper_L };
};Then I load this with the following in my .profile before launching my compositor (though sway has it's own config options for this):
export XKB_DEFAULT_LAYOUT=us-customThe name us-custom is arbitrary, but it's my customization of the 'us' layout.
To get the content you need, look at /usr/share/X11/xkb/symbols/us (or whichever base layout you use). In that file you can see lines like the following for Insert:
key <KP0> { [ KP_Insert, KP_0, mu, mu ] };So in your custom file you'd have something like this:
key <KP0> { [ KP_Delete ] };Though you may want to provide keysyms for the other "levels" as well in that list - that's up to you. But the following untested layout should give a us layout with the Insert key acting as a (second) Delete key:
partial alphanumeric_keys
xkb_symbols "classmate-intl" {
include "us(intl)"
name[Group1]= "English (US, Custom)";
key <KP0> { [ KP_Delete ] };
};EDIT: I just revised the above example as that key code is not in the "basic" section in the base layout but rather in "classmate-intl". I don't have experience overriding keypad keys or keys in other sections of the layout. I'm not sure if the "basic" section still needs to be included, e.g.:
default partial alphanumeric_keys modifier_keys
xkb_symbols "basic" {
include "us"
name[Group1]= "English (US, Custom)";
};
partial alphanumeric_keys
xkb_symbols "classmate-intl" {
include "us(intl)"
name[Group1]= "English (US, Custom)";
key <KP0> { [ KP_Delete ] };
};Last edited by Trilby (2023-03-12 23:01:01)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
If I only supply the changes to the file, then the layout becomes US, so I have kept everything
cp /usr/share/X11/xkb/symbols/dk ~/.xkb/symbols/custom and added
partial alphanumeric_keys
xkb_symbols "classmate-intl" {
include "dk(intl)"
name[Group1]= "Custom";
key <KP0> { [ KP_Delete ] };
};and then added
input type:keyboard {
xkb_layout dk
xkb_options caps:none
}
input * xkb_layout customin Sway config, so I don't have to reboot to test every test. I hope this is ok?
When I make the above, then Insert doesn't print anything on the first press. On second press
^[[2~So something is happening, just not delete a character to the right.
Any idea what could be the problem?
Offline
I'm a bit out of my depth with that one, but the dk layout does not actually define a Delete keysym itself but rather includes other layouts that do. It looks like the dk layout gets the Delete definition from kpdl. So you'd have to base your block on the kpdl block (for kpdl(comma)):
xkb_symbols "comma" {
key.type[Group1]="KEYPAD" ;
key <KPDL> { [ KP_Insert, KP_Separator ] };
};Note that overriding layouts that include several other layouts can get a bit confusing - and for me would take quite a lot of exploration and trial and error. That's a good way to learn a lot about xkb, but if you just want results, you may want to look into one of the layout-editor tools. I have no recommendation as I've never used any of them, but I know they exist for this purpose.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I'm a bit out of my depth with that one, but the dk layout does not actually define a Delete keysym itself but rather includes other layouts that do. It looks like the dk layout gets the Delete definition from kpdl. So you'd have to base your block on the kpdl block (for kpdl(comma)):
xkb_symbols "comma" { key.type[Group1]="KEYPAD" ; key <KPDL> { [ KP_Insert, KP_Separator ] }; };Note that overriding layouts that include several other layouts can get a bit confusing - and for me would take quite a lot of exploration and trial and error. That's a good way to learn a lot about xkb, but if you just want results, you may want to look into one of the layout-editor tools. I have no recommendation as I've never used any of them, but I know they exist for this purpose.
Ok, that is interesting. Should I make a copy of "/usr/share/X11/xkb/symbols/kpdl" to ~/.xkb/symbols" and then edit that? If so, how does my modified dk know that it should use my local kpdl?
Searching for editors, these come up
* https://github.com/NapoleonWils0n/cerbe … nd-xkb.org
* https://unix.stackexchange.com/question … th-wayland
They talk about ecdev and xml files. Given I don't use Gnome, can I still use this?
Offline
I got it solved.
yay -S input-remapper-git
sudo systemctl restart input-remapper
sudo systemctl enable input-remapper
sudo -E input-remapper-gtk and what is particular cool about this, is it is easy and it works system wide. In all X, Wayland, and TTY's.
And it even works correct in Firefox, Chrome, VSCode. Xmodmap eg. did not work there when I was in X.
And it is remapper pr input device. So it only remaps the keys when your specific keyboard is connected.
Just all around awesome!
Thanks a bunch Trilby for all the time and help you have put in helping me. I wouldn't have found this editor if you hadn't mentioned that option.
Offline