MacOS keyboard layout on Linux

1 minute read

Build a budget 3090 deep learning workstation Bonus: How to set up a MacOS keyboard layout on Linux (Ubuntu, Fedora, etc)

Earlier parts of “Build a budget ML workstation”

  • Part Zero: Random tidbits: a newbie’s story to build a budget machine learning workstation.
  • Part One: Building: assembling the parts and how to deal with the bent of the big and heavy RTX 3090.
  • Part Two: software and CUDA: we will learn how to install CUDA and PyTorch, and how to config Ubuntu so that the GPU is NOT used for graphics displaying but only for CUDA computing.
  • Part Three: undervolt the GPU: we will see how to config the Ubuntu to achieve an undervolt effect on GPU, thus making the system more stable. This serves our need of training of models for a longer period of time.

MacOS keyboard config on Ubuntu

The last part may be irrelevant to making the system’s running more sustainable but rather about productivity. As I am using Logitech MX keyboard and mouse across a MacOS and Ubuntu, it is much easier to have ⌘ Command acting as Ctrl key, and ⌥ Option as Alt.

Upon a simple Google-fu I found that installing gnome-tweak-tool would do the trick. Go to “Tweak->K&M->Additional Keyboard Layout” and do a simple key mapping:

However, after rebooting the setup is reset…after more Google-fu the solution is to impose a more system-wide boot option. Upon sudo-editing or creating /etc/default/keyboard, adding the line about XKBOPTIONS would do the trick.

XKBLAYOUT=us
BACKSPACE=guess
XKBOPTIONS="altwin:ctrl_alt_win"

If we want to know what possible key swap options are for Ctrl, we can do

man -P cat xkeyboard-config | grep ctrl

While the system wide setting is good, the following VSCode key bindings json would do the trick to make the experience in VSCode almost completely conforming to that on MacOS. Simply Ctrl+ Alt+ P, and search for keyboard, open up the non-default one, and copy-pasta the following bindings we are good to go!

Comments