How do you remap keyboard keys in Linux?

For context, I use Asahi’s Arch Linux running Wayland KDE on an M1 Mac with a touch bar. (Don’t anyone tell me it’s uNsUpOrTeD, OK?)


I’m trying to remap my apple keyboard’s modifier keys. Specificaly, I’m aiming for:

  • Command ⌘ changed to Control ^
  • Option ⌥ left as Alt
  • Control ^ left as Control ^ (yes 2 control keys)
  • Function 🌐 changed to the Super/Windows key
  • And when Caps lock ⇪ is held down, the number keys become function keys (Like how Fn originaly acted)

(This weird configuration is beacuse of the touch bar, so no function keys, and Macs have an extra modifier key (fn). I will probably change some of these later, like the 2 control keys.)


What I’ve tried

Method Problem
Creating and editing /etc/udev/hwdb.d/90-custom-modifiers.hwdb When running sudo systemd-hwdb update I get the error: /etc/udev/hwdb.d/90-custom-modifiers.hwdb:5: Property expected, ignoring record with no properties. EVEN THOUGH NOTHING IS WRONG
Installing and configuring keyd Nothing happens
Editing files from /usr/share/X11/xkb/symbols/ and running setxkbmap -layout [FILE] I’m using Wayland WARNING: Running setxkbmap against an Xwayland server
Using KDE Settings (System Settings > Keyboard > Keyboard > Key Bindings) Doesn’t do what I need (and who on earth designed that?)
Using xmodmap Only works for the current user, only works in Xorg (I’m using Wayland).
Editing /etc/modprobe.d/hid_apple.conf Doesn’t do everything I need

I’ve been trying to solve this for way too long, and nothing online is helping. Any help is appriciated.