Skip to content

Instantly share code, notes, and snippets.

@edliaw
Last active April 23, 2024 18:32
Show Gist options
  • Save edliaw/11005709 to your computer and use it in GitHub Desktop.
Save edliaw/11005709 to your computer and use it in GitHub Desktop.
Custom keyboard layout for GNOME
[Desktop Entry]
Name=Keyboard Layout
Type=Application
Exec=sh -c "sleep 10 && [ -f \\$HOME/.Xkeymap ] && xkbcomp \\$HOME/.Xkeymap \\$DISPLAY 2> /dev/null"
Terminal=false
NoDisplay=true
X-GNOME-Autostart-enabled=true
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us_custom+inet(evdev)" };
};
default partial alphanumeric_keys modifier_keys
xkb_symbols "us_custom" {
include "us(basic)"
name[Group1]= "English (custom layout)";
key.type[Group1]="ONE_LEVEL";
key <ESC> { [ Caps_Lock ] };
key <CAPS> { [ Control_L ] };
key <LCTL> { [ Escape ] };
};
@edliaw
Copy link
Author

edliaw commented Apr 17, 2014

Custom symbol file goes into /usr/share/X11/xkb/symbols/us_custom

Then, add to /usr/share/X11/xkb/rules/evdev.xml:

    <layout>
      <configItem>
        <name>us_custom</name>

        <shortDescription>en_custom</shortDescription>
        <description>English (custom layout)</description>
        <languageList>
          <iso639Id>eng</iso639Id>
        </languageList>
      </configItem>
      <variantList/>
    </layout>

@edliaw
Copy link
Author

edliaw commented Oct 16, 2015

Alternatively, with the symbol file at $HOME/.xkb/symbols/us_custom and keymap at $HOME/.xkb/keymap.xkb:
Running xkbcomp -I$HOME/.xkb $HOME/.xkb/keymap.xkb $DISPLAY will compile and load the keymap.

You can also dump the current keymap using xkbcomp $DISPLAY $HOME/.Xkeymap and create a GNOME desktop file to autoload it on boot in ~/.config/autostart/custom_xkb.desktop.

References:
http://www.x.org/wiki/XKB/
https://wiki.archlinux.org/index.php/X_KeyBoard_extension

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