Personal configuration files for Ubuntu on a Dell XPS 13
usr/share/X11/xkb
contains
XKB
configuration files for achieving a UNIX-like layout on today's
prevailing U.S. PC keyboards, where Caps lock is on the left edge of
the keyboard, Control is in the lower left corner, Escape is in the
top left corner beside the function keys, Backspace is one row below
on the right edge, and Backslash is one row below that one and also on
the right edge.
By "UNIX-like," I mean the layout found on the Happy Hacking Keyboard, where
- Control is the leftmost key on the home row,
- Escape is directly to the left of the number keys,
- Backspace (or Delete) is directly above Enter,
- Backslash is above Backspace, and
- there is no dedicated Caps lock key.
The Happy Hacking and Sun Type 3 keyboards split what is the Backspace key on PC keyboards into two—Backslash and Tilde—so I put Tilde elsewhere.
To install this layout:
mv /usr/share/X11/xkb/rules/evdev.lst /usr/share/X11/xkb/rules/evdev.lst.orig
mv /usr/share/X11/xkb/rules/evdev.xml /usr/share/X11/xkb/rules/evdev.xml.orig
cp usr/share/X11/xkb/rules/evdev.lst usr/share/X11/xkb/rules/evdev.xml \
/usr/shareX11/xkb/rules/
cp usr/share/X11/xkb/symbols/us-unix /usr/shareX11/xkb/symbols/
To apply this layout on the built-in keyboard of a Dell XPS 13 (9380):
setxkbmap -layout us-unix -option
setxkbmap -layout us-unix -option "altwin:swap_alt_win,ctrl:rctrl_ralt"
To use in i3, you can create a script to set the layout and invoke the script from the i3 configuration file.
For example, the contents of ~/.local/bin/setkeyboardlayout
:
#!/usr/bin/env bash
if setxkbmap -layout us-unix -option &>/dev/null; then
setxkbmap -layout us-unix -option "altwin:swap_alt_win,ctrl:rctrl_ralt"
exit
fi
# On a US layout:
# - Swap Caps lock and left Control
# - Swap Alt and Super
# - Make right Control invoke right Alt
setxkbmap -layout us -option
setxkbmap -layout us -option "ctrl:swapcaps,altwin:swap_alt_win,ctrl:rctrl_ralt"
Then add this line to ~/.config/i3/config
:
exec --no-startup-id ~/.local/bin/setkeyboardlayout
Some helpful information for defining keyboard layouts in XKB: