Below, you'll find the steps required to create a systemd command that will run at boot to disable the media keys and restore f1-f12 functionality.
Open a terminal window and create a new file in the folder
/etc/systemd/system/.
File name should be keychron.service
sudo nvim /etc/systemd/system/keychron.service
nvim can be exchanged for any editor of your choice for example doom emacs.
Paste the following code into the window:
[Unit]
Description=The command to make the Keychron K2-k4 work with Function keys
[Service]
Type=oneshot
ExecStart=/bin/bash -c "sudo echo 1 | sudo tee /sys/module/hid_apple/parameters/fnmode"
ExecStop=/bin/bash -c "sudo echo 0 | sudo tee /sys/module/hid_apple/parameters/fnmode"
[Install]
WantedBy=multi-user.target
To exit nvim press escape
then :
then w
q
and enter.
In the terminal, in order to enable the service type the following:
sudo systemctl enable keychron
To see the changes right away run last command:
sudo systemctl start keychron
If you want to simply drag/drop the file that you create manually in the steps provided, I have it under the scripts folder in this repo. Download it and drop it in /etc/systemd/system/
, doing Step 3 at the end.