Skip to content

Instantly share code, notes, and snippets.

@andramalech
Forked from andrebrait/keychron_linux.md
Created November 26, 2020 01:03
Show Gist options
  • Save andramalech/a51c7db10185db44279c873bffa1e482 to your computer and use it in GitHub Desktop.
Save andramalech/a51c7db10185db44279c873bffa1e482 to your computer and use it in GitHub Desktop.
Keychron keyboards on Linux (+ bluetooth fixes)

Here the best setup (I think so :D) for Keychron + Linux

Make Fn + F-keys work

  • Step 1: Set fkeyfirst by:
    • Create the file /etc/modprobe.d/hid_apple.conf. Add this line to the file: options hid_apple fnmode=2
    • Save the file and execute the following command: sudo update-initramfs -u
    • Reboot
  • Step 2: Use the keyboard in Windows/Android mode
  • Step 3: If get stuck with numpad mode: Double hit F6 or fn + F6. I've been using this config since the very first day, both bluetooth and cable with no problem.

Alternative config:

  • For step 1: you can just do echo 2 | tee sudo /sys/module/hid_apple/parameters/fnmode instead.
  • But the setting will be reset after reboot, so the method above is to make sure that the setting is permanent after reboot. Also someone recommends to create a udev rule for keychron devices.

Enable bluetooth fastconnect config:

  1. Edit the file /etc/bluetooth/main.conf
  2. Uncomment FastConnectable config and set it to true: FastConnectable = true
  3. Uncomment ReconnectAttempts=7 (set the value to whatever number that you want)
  4. Uncomment ReconnectIntervals=1, 2, 3

Disable Autosuspend for USB Bluetooth dongles:

Run the following command:

echo -e "# Disable autosuspend for btusb to make the bluetooth keyboard work again\noptions btusb enable_autosuspend=n" | sudo tee /etc/modprobe.d/btusb_disable_autosuspend.conf

Now reboot your computer, or run:

sudo modprobe -r btusb
sudo service bluetooth restart
sudo modprobe btusb

Enable bluetooth after sleep:

Create and edit a file that will be executed every time the computer wakes up:

sudo nano /lib/systemd/system-sleep/bt

Add this to its contents:

#!/bin/sh

case $1 in
  post)
    modprobe -r btusb
    sleep 1
    service bluetooth restart
    sleep 1
    modprobe btusb
    ;;
esac

Make it executable

sudo chmod +x /lib/systemd/system-sleep/bt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment