Trying to fix up the fn keys on my apple keyboard on CentOS 7, I’ve set
$ cat /etc/modprobe.d/hid_apple.conf options hid_apple fnmode=2
and yet after a reboot
$ cat /sys/module/hid_apple/parameters/fnmode 1
Suggestions on the internet include running update-initramfs, which doesn’t seem to exist on Centos 7, and doing the “echo 2 >> /sys/module/hid_apple/parameters/fnmode” in /etc/rc.local, which of course doesn’t exist at all any more under systemd.
What’s the right way to persist that setting?
Advertisement
Answer
There are 3 ways in which you can achieve this:
- rc.local (Still works, remember to chmod +x after adding your lines)
- systemd
- udev rules (My own preferred)
With systemd:
# /etc/systemd/system/hid_apple_fnmode_set.service [Unit] Description=Set Apple keyboard fn mode After=multi-user.target [Service] ExecStart=/usr/bin/bash -c '/usr/bin/echo 2 > /sys/module/hid_apple/parameters/fnmode' [Install] WantedBy=graphical.target
Followed by this to make the service run at boot.
sudo systemctl enable hid_apple_fnmode_set.service
With udev rules:
# /etc/udev/rules.d/99-hid_apple.rules SUBSYSTEM=="module", DRIVER=="hid_apple", ATTR{parameters/fnmode}="2"
The systemd script and udev rules are put together with some wild guesses, might take some tweaking to work. The following commands can help adjust and debug the udev rule:
udevadm info --attribute-walk --path=/module/hid_apple udevadm test /sys/module/hid_apple/