Setting `/sys/module/hid_apple/parameters/fnmode` to `0` at boot?

I just bought a Keychron K2 and it seems to have some problems with the F-keys on Linux, but the fix is simple enough:

echo 0 | sudo tee /sys/module/hid_apple/parameters/fnmode

If I run this the keyboard works fine, but I was wondering, how can I do the equivalent in mijn configuration.nix to make that fix permanent?

Thanks!

2 Likes

For now I’m using:

  system.activationScripts = {
    keychronk2fix.text =
      ''
        # Fix for the f-keys of the Keychron K2:
        echo 0 | tee /sys/module/hid_apple/parameters/fnmode >/dev/null
      '';
  };

And that seems to work.

I think it should be possible to persist it with this, which tells modprobe to pass fnmode=0 by default when loading the hid_apple kernel module:

{
  boot.extraModprobeConfig = ''
    options hid_apple fnmode=0
  '';
}
4 Likes

Looks like that worked too! :smiley: And feels like a better solution than mine.

Thanks!