├── LICENSE ├── README.md └── script └── keychron.service /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Adam Savard 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Enable Function Keys On Keychron/Various Mechanical Keyboards Under Linux, with `systemd` 3 | 4 | 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. Note that these steps have been tested with Keychron keyboards in Windows Mode, _not_ Mac Mode. 5 | 6 | ## Step 1 7 | 8 | Open a terminal window and enter the following command: 9 | 10 | ```shell 11 | # Set the EDITOR variable with EDITOR=nano, uncommenting the line directly below 12 | # EDITOR=nano 13 | sudoedit /etc/systemd/system/keychron.service 14 | ``` 15 | 16 | ## Step 2 17 | 18 | Paste the following into the window: 19 | 20 | ``` 21 | [Unit] 22 | Description=Disable media keys and substitute in function keys 23 | 24 | [Service] 25 | Type=simple 26 | RemainAfterExit=yes 27 | ExecStart=/bin/bash -c "echo 0 > /sys/module/hid_apple/parameters/fnmode" 28 | ExecStop=/bin/bash -c "echo 1 > /sys/module/hid_apple/parameters/fnmode" 29 | 30 | [Install] 31 | WantedBy=multi-user.target 32 | ``` 33 | 34 | Press `ctrl+o` and then `ctrl+x` to exit. 35 | 36 | ## Step 3 37 | 38 | In the terminal, type the following: 39 | 40 | `systemctl enable keychron` 41 | 42 | ## Step 4 43 | 44 | That's it! A reboot, and you'll see that the function keys have been re-enabled. 45 | Alternatively, run this command to see the changes right away: 46 | `systemctl start keychron` 47 | 48 | # Contributing 49 | 50 | If you confirm that your keyboard works with this script as expected, create a ticket and I'll add it to the list of user-tested keyboards. Alternatively, submit a PR with a modification to this readme. 51 | 52 | # User Tested Keyboards 53 | - [Keychron K2](https://github.com/adam-savard/keychron-k2-function-keys-linux/issues/9) 54 | - [Keychron K1 SE](https://github.com/adam-savard/keychron-k2-function-keys-linux/issues/9) 55 | - [Keychron K6](https://github.com/adam-savard/keychron-k2-function-keys-linux/issues/9) 56 | - [Keychron C2](https://github.com/adam-savard/keychron-k2-function-keys-linux/issues/12) 57 | - [Keychron K8](https://github.com/adam-savard/keychron-k2-function-keys-linux/issues/9) 58 | - [Ninja87BT](https://github.com/adam-savard/keychron-k2-function-keys-linux/issues/13) 59 | - [Keychron K4](https://github.com/adam-savard/keychron-k2-function-keys-linux/issues/14) 60 | - [Keychron C1](https://github.com/adam-savard/keyboard-function-keys-linux/issues/19) 61 | - [Flesports MK870](https://github.com/adam-savard/keyboard-function-keys-linux/issues/21) 62 | - [Keebmonkey 1800/James Donkey RS2](https://github.com/adam-savard/keyboard-function-keys-linux/issues/20) 63 | - [Keychron K3E1](https://github.com/adam-savard/keyboard-function-keys-linux/issues/23) 64 | 65 | ## Closing Remarks 66 | 67 | 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. 68 | -------------------------------------------------------------------------------- /script/keychron.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Disable media keys and substitute in function keys 3 | 4 | [Service] 5 | Type=simple 6 | RemainAfterExit=yes 7 | ExecStart=/bin/bash -c "echo 0 > /sys/module/hid_apple/parameters/fnmode" 8 | ExecStop=/bin/bash -c "echo 1 > /sys/module/hid_apple/parameters/fnmode" 9 | 10 | [Install] 11 | WantedBy=multi-user.target 12 | --------------------------------------------------------------------------------