Article 4QD08 Customizing keyboard layout (xkb)

Customizing keyboard layout (xkb)

by
justasalad
from LinuxQuestions.org on (#4QD08)
I have a Chromebook and on the top row there are 10 media keys. Currently, they all act as media keys except when I hold down an overlay key (Super_L) which then maps them to F1-F10. The only change I want is to remap media keys 1-5 to F1-F5 (so that I don't have to hold down the overlay key). I don't need media keys 1-5 (with or without overlay) because they're useless to me.

I was hoping I could solve this with xmodmap but it seems it doesn't play well with xkb (I lack the patience to learn all the xkb stuff...) Here's what happens when I use xmodmap:

Code:showkey -kI press media key 1 and it prints:
Quote:
keycode 59 press
next I remap with
Code:xmodmap -e "keycode 59 = F1"But media key 1 is still mapped to XF86Back and instead.... "comma" (next to M on my keyboard) is now mapped to F1. Weird.

If you happen to understand the quirks with xmodmap and help fix this, or if you could help me edit the necessary files in /usr/share/X11/xkb I would be really grateful! Info about my current layout:
Quote:
dava@debian:~$ setxkbmap -query
rules: evdev
model: chromebook_m
layout: se
I don't know what file(s) I need to edit and there's A LOT of "chromebook" stuff in /usr/share/X11/xkb
Quote:
dava@debian:~$ find /usr/share/X11/xkb -name "chromebook*"
/usr/share/X11/xkb/symbols/chromebook
/usr/share/X11/xkb/symbols/chromebook_ralt
/usr/share/X11/xkb/symbols/chromebook_m
/usr/share/X11/xkb/symbols/chromebook_m_ralt
/usr/share/X11/xkb/symbols/chromebook_m.backup
/usr/share/X11/xkb/keycodes/chromebook_m
/usr/share/X11/xkb/compat/chromebook
Quote:
dava@debian:~$ grep -ril "chromebook" /usr/share/X11/xkb
/usr/share/X11/xkb/rules/base.lst
/usr/share/X11/xkb/rules/evdev
/usr/share/X11/xkb/rules/base.xml
/usr/share/X11/xkb/rules/evdev.xml
/usr/share/X11/xkb/rules/evdev.lst
/usr/share/X11/xkb/rules/base
Here are two files I think I need to edit, but maybe I will need to edit other files as well??

/usr/share/X11/xkb/keycodes/chromebook_m
Quote:
default xkb_keycodes "media" {
<FK01> = 166; //Back
<FK02> = 167; //Forward
<FK03> = 181; //Refresh
<FK04> = 160; //Video next
<FK05> = 235; //Video mode
<FK06> = 232; //Brightness down
<FK07> = 233; //Brightness up
<FK08> = 121; //Mute
<FK09> = 122; //Volume -
<FK10> = 123; //Volume +

<I166> = 67; // #define KEY_BACK
<I167> = 68; // #define KEY_FORWARD
<I181> = 69; // #define KEY_REFRESH
<I160> = 70; // #define KEY_COFFEE
<I235> = 71; // #define KEY_SWITCHVIDEOMODE
<I232> = 72; // #define KEY_BRIGHTNESSDOWN
<I233> = 73; // #define KEY_BRIGHTNESSUP
<MUTE> = 74;
<VOL-> = 75;
<VOL+> = 76;
};
/usr/share/X11/xkb/symbols/chromebook_m
Quote:
// This mapping assumes that inet(evdev) will also be sourced
partial
xkb_symbols "overlay" {
key <LWIN> { [ Overlay1_Enable ], overlay1=<LWIN> };
key <I225> { [ Overlay1_Enable ], overlay1=<I225> };

key <AB09> { overlay1=<INS> };

key <LEFT> { overlay1=<HOME> };
key <RGHT> { overlay1=<END> };
key <UP> { overlay1=<PGUP> };
key <DOWN> { overlay1=<PGDN> };

key <I166> { overlay1=<FK01> };
key <I167> { overlay1=<FK02> };
key <I181> { overlay1=<FK03> };
key <I160> { overlay1=<FK04> };
key <I235> { overlay1=<FK05> };
key <I232> { overlay1=<FK06> };
key <I233> { overlay1=<FK07> };
key <MUTE> { overlay1=<FK08> };
key <VOL-> { overlay1=<FK09> };
key <VOL+> { overlay1=<FK10> };

key <AE01> { overlay1=<FK01> };
key <AE02> { overlay1=<FK02> };
key <AE03> { overlay1=<FK03> };
key <AE04> { overlay1=<FK04> };
key <AE05> { overlay1=<FK05> };
key <AE06> { overlay1=<FK06> };
key <AE07> { overlay1=<FK07> };
key <AE08> { overlay1=<FK08> };
key <AE09> { overlay1=<FK09> };
key <AE10> { overlay1=<I236> }; // KEY_KBDILLUMTOGGLE
key <AE11> { overlay1=<I237> }; // KEY_KBDILLUMDOWN
key <AE12> { overlay1=<I238> }; // KEY_KBDILLUMUP
key <BKSP> { overlay1=<DELE> };

key <LALT> { overlay1=<CAPS> };
key <RALT> { overlay1=<CAPS> };

// For some strange reason, some Super_R events are triggered when
// the Search key is released (i.e. with overlay on).
// This maps RWIN to a dummy key (<I253>), to make sure we catch it.
key <RWIN> { [ NoSymbol ], overlay1=<I253> };

// Map dummy key to no symbol
key <I253> { [ NoSymbol ] };
};
latest?d=yIl2AUoC8zA latest?i=5WZIurhPgdc:ixWZd5L8QpQ:F7zBnMy latest?i=5WZIurhPgdc:ixWZd5L8QpQ:V_sGLiP latest?d=qj6IDK7rITs latest?i=5WZIurhPgdc:ixWZd5L8QpQ:gIN9vFw5WZIurhPgdc
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments