Support #810
Setup a Bluetooth Keyboard on Arch Linux
Description
This is a guide on how I setup a bluetooth keyboard on Arch Linux.
Prepare the Environment¶
- Make sure the system is up to date:
sudo pacman -Syu
Install Bluetooth¶
- Install the bluez packages:
sudo pacman -S bluez bluez-utils
- Start and enable the bluetooth service at boot:
sudo systemctl enable bluetooth sudo systemctl start bluetooth
- Use
bluetoothctl
for the pairing process:bluetoothctl -a
- While in bluetoothctl power up the controller:
power on
- Next, tell bluetoothctl to look only for keyboards, and make that the default agent:
agent KeyboardOnly default-agent
- Next, put the controller (the local dongle) in pairable mode:
pairable on
- Next, put the keyboard in an active mode, where it is discoverable, i.e. pairable.
- Then, let the controller scan the BT frequencies for a suitable device:
scan on
- Next, actually do the pairing. The address used is the BT-MAC address of the keyboard:
pair 01:02:03:04:05:06
- Next, make this a trusted device (this allows the device to establish the connection on itself). Again, the BT-MAC address is the address of the keyboard device:
trust 01:02:03:04:05:06
- Finally connect to the device (keyboard). Again, the BT-MAC address is the address of the keyboard device:
connect 01:02:03:04:05:06
- Leave the bluetoothctl utility:
quit
- While in bluetoothctl power up the controller:
Automatically enabling a Bluetooth Keyboard¶
NOTE: Remember that you have to pair and trust your device in bluetoothctl to cause autoconnect.
Custom systemd service file:
- Create a bluetooth keyboard config file:
sudo vi /etc/btkbd.conf
- And add the following:
# Config file for btkbd.service # change when required (e.g. keyboard hardware changes, more hci devices are connected) BTKBDMAC = "01:02:03:04:05:06" HCIDEVICE = "hci0"
- And add the following:
- Next, create a new bluetooth keyboard service file:
sudo vi /etc/systemd/system/btkbd.service
- And add the following:
[Unit] Description=systemd Unit to automatically start a Bluetooth keyboard Documentation=https://wiki.archlinux.org/index.php/Bluetooth_Keyboard Requires=dbus-org.bluez.service After=dbus-bluez.org.service ConditionPathExists=/etc/btkbd.conf ConditionPathExists=/usr/bin/hcitool ConditionPathExists=/usr/bin/hciconfig [Service] Type=oneshot EnvironmentFile=/etc/btkbd.conf ExecStart= ExecStart=/usr/bin/hciconfig ${HCIDEVICE} up # ignore errors on connect, spurious problems with bt? so start next command with - ExecStart=-/usr/bin/hcitool cc ${BTKBDMAC} [Install] WantedBy=multi-user.target
- And add the following:
- Then reload systemd and enable the service at boot:
sudo systemctl daemon-reload sudo systemctl enable btkbd sudo systemctl start btkbd