Skip to content

Instantly share code, notes, and snippets.

@guziy
Last active January 30, 2024 04:46
Show Gist options
  • Save guziy/d03e535d445404352d955a11e5dd8923 to your computer and use it in GitHub Desktop.
Save guziy/d03e535d445404352d955a11e5dd8923 to your computer and use it in GitHub Desktop.
# check the current layout settings
localectl status
# System Locale: LANG=en_CA.UTF-8
# VC Keymap: ca-multix
# X11 Layout: ca
# X11 Model: apple
# X11 Variant: multix
# the command to set keyboard layout is
# localectl set-x11-keymap LAYOUT [MODEL [VARIANT [OPTIONS]]]
# so we need to figure out what to put
# for LAYOUT MODEL and VARIANT for my keyboard
# to list all available layouts
localectl list-x11-keymap-layouts
# from the output of the above command
# I figured that LAYOUT=ca in my case
# now there is a command to list available models
# since I was interested in apple, I added a grep
localectl list-x11-keymap-models | grep -i apple
# apple
# apple_laptop
# applealu_ansi
# applealu_iso
# applealu_jis
# from the above I figured that for me MODEL=apple
# would be a good first guess.
# Now we need to figure out the value for the VARIANT
# for LAYOUT=ca
localectl list-x11-keymap-variants ca
# eng
# fr-dvorak
# fr-legacy
# ike
# multix
# I tried using fr-dvorak and it was a disaster,
# it completely messed up my keyboard,
# using trial and error approach I realized that VARIANT=multix
# for my Apple keyboard with numeric keypad.
# So, finally I have all the ingredients
# to set my layout as follows
localectl set-x11-keymap ca apple multix
# and use cmd+shift+e to exit i3 and then
# login again and enjoy a nicely working keyboard in i3))
## UPDATE:
# I needed the left option/alt key to behave as altgr, it is just easier to type the curly and
# square brackets on the apple keyboard, to achieve this you would need to add the
# following argument to the localectl command 'lv3:alt_switch' as below:
localectl set-x11-keymap ca \
apple \
multix
# I used the following to swap left and right alts
setxkbmap -option lv3:lalt_switch -option lv3:ralt_alt
# to save the above setxkbmap options for switching alts, modify /etc/default/keyboard as follows:
cat /etc/default/keyboard
'''
# KEYBOARD CONFIGURATION FILE
# Consult the keyboard(5) manual page.
XKBMODEL="apple"
XKBLAYOUT="ca"
XKBVARIANT="multix"
XKBOPTIONS="lv3:lalt_switch,lv3:ralt_alt"
BACKSPACE="guess"
'''
# To persist the switch of the left-right alts in i3
# I had to add the following to the ~/.config/i3/config
exec --no-startup-id setxkbmap -option lv3:lalt_switch -option lv3:ralt_alt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment