Make MacBook media keys (volume, brightness, keyboard backlight, mission control) work without holding Fn on Linux — the way they do on macOS by default.
If your top-row keys behave as F1–F12 by default and you have to press Fn to change volume or brightness, this is for you.
echo "options hid_apple fnmode=1" | sudo tee /etc/modprobe.d/hid_apple.conf
echo 1 | sudo tee /sys/module/hid_apple/parameters/fnmodeThen rebuild the initramfs (pick the one for your distro):
sudo dracut --force # Fedora, RHEL, openSUSE
sudo update-initramfs -u # Ubuntu, Debian, Linux Mint, Pop!_OS
sudo mkinitcpio -P # Arch, Manjaro, EndeavourOSThat's it. No reboot needed for the current session — the second line applies the change live. The first and third lines make it persist across reboots.
git clone https://github.com/vitaliebumbu/macbook-fn-keys-linux.git
cd macbook-fn-keys-linux
sudo ./install.shThe script writes the modprobe config, applies the live setting, and auto-detects which initramfs tool your distro uses (dracut, update-initramfs, or mkinitcpio).
To revert to the kernel default: sudo ./uninstall.sh.
Apple keyboards on Linux are handled by the hid_apple kernel module, which has an fnmode parameter. Setting it to 1 makes the printed top-row functions (volume, brightness, etc.) primary, and shifts F1–F12 behind the Fn modifier — matching macOS behavior.
The initramfs contains its own copy of /etc/modprobe.d/. Because hid_apple loads very early in boot (so the keyboard works during LUKS unlock and similar), the option needs to be baked into the initramfs as well. If you skip this step, your setting only applies after userspace finishes booting and you may see old behavior at boot, on suspend/resume, or at the LUKS prompt.
| Value | Name | Behavior |
|---|---|---|
0 |
disabled | Fn does nothing |
1 |
fkeyslast | Media keys primary, Fn → F1–F12 (macOS default) |
2 |
fkeysfirst | F1–F12 primary, Fn → media keys |
3 |
auto | Kernel decides based on keyboard model (kernel default on recent versions) |
4 |
fkeysdisabled | F-keys disabled — only media keys |
Check your current value:
cat /sys/module/hid_apple/parameters/fnmodeYou can stack these in the same config file:
options hid_apple fnmode=1 swap_opt_cmd=1 iso_layout=0
| Option | Effect |
|---|---|
swap_opt_cmd=1 |
Swap Option/Alt and Command/Super system-wide (PC-style layout) |
swap_opt_cmd=2 |
Same, but only on the left side |
swap_ctrl_cmd=1 |
Swap Control and Command (so Cmd+C etc. work like macOS) |
swap_fn_leftctrl=1 |
Swap Fn and Left Ctrl (puts Ctrl in the corner like a PC) |
iso_layout=0 |
Disable the backtick/tilde and greater/less-than swap on ISO keyboards |
After changing the config, run the same initramfs-rebuild command again.
- Fedora 43 (kernel 6.19) — MacBook Pro 11,4 (Mid-2015 Retina 15")
hid_apple ships with the mainline Linux kernel, so this works on essentially any distro and any Mac model with an Apple-branded keyboard (built-in or USB/Bluetooth Magic Keyboard).
Nothing changed.
Run lsmod | grep hid_apple — the module must be loaded for the runtime change to apply. If it isn't, the persistent config will still take effect after the next reboot (once the initramfs is rebuilt).
My change didn't survive reboot.
You almost certainly skipped the initramfs rebuild. Run sudo dracut --force (or the equivalent for your distro) and reboot.
Some keys still need Fn.
A few combinations (e.g. Fn+Backspace for forward delete, Fn+Arrow for Home/End/PgUp/PgDn) are intentional and not affected by fnmode.
Keyboard-backlight key does nothing in my window manager.
GNOME and KDE handle it natively. On minimal WMs you may need to bind the key yourself — for example to a script that writes to /sys/class/leds/*::kbd_backlight/brightness.
It works in the desktop but the LUKS prompt still uses the old behavior. That's the initramfs talking. Rebuild it as above.
MIT — see LICENSE.