--- layout: post title: "Get a Bluetooth keyboard work with Arch Linux" date: 2016-07-07 14:49:18 +0200 categories: linux ---
I've recently got a Rapoo E6100. This is a minimal and space saving Bluetooth
3.0 keyboard. If you pair it with Windows 10, it will remain paired after
reboot, giving the possibility to use it since the login screen. After
installing the Bluetooth stack on my Arch via the bluez
and
bluez-utils
packages I thought the pairing process would be as
simple as Windows if I used the KDE GUI menus for Bluetooth management. That's
not true. The keyboard, once paired, will reconnect automatically just after
plasmashell
loaded, leaving me without keyboard during the SDDM
login screen and, of course, during a non-graphical session.
As usual, i've searched help in the ArchWiki, founding
this
article. With that, i've succesfully reconnected my Bluetooth keyboard using
the bluetoothctl
utility. The next step was configuring the
service for auto connection during boot. I've created the
btkbd.conf
and the btkbd.service
files, enabling the
last one with systemd. Let's give a look to the service file:
{% highlight bash linenos %} [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-org.bluez.service ConditionPathExists=/etc/btkbd.conf ConditionPathExists=/usr/bin/hcitool ConditionPathExists=/usr/bin/hciconfig [Service] Type=oneshot EnvironmentFile=/etc/btkbd.conf 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 {% endhighlight %}
Line 13 enables the Bluetooth dongle, and line 16 connects it to the keyboard
we gave the mac address in /etc/btkbd.conf
. This should work
flawlessly, right? Of course it doesn't. The service starts before the
dbus-org.bluez.service
is loaded and fails. However, if the
service is started manually after login the Bluetooth keyboard works. After
hours of trying figuring out what was wrong I've almost asked for a return on
Amazon! The last attempt I made was with sddm disabled and involved built from
scratch service:
{% highlight bash linenos %} [Unit] Description=systemd Unit to automatically start a Bluetooth keyboard [Service] Type=oneshot ExecStart=/bin/hciconfig hci0 up ExecStart=/bin/hcitool cc 00:11:22:33:44:55 [Install] WantedBy=bluetooth.target {% endhighlight %}
This incredibly worked. I think the problem was that
multi-user.target
that needs to be reached earlier than
bluetooth.target
. I got rid of all the tidiness of the ArchWiki
solution just to be sure that was not the problem, but I think you can use all
of that just correcting WantedBy=
. Currently I haven't an
ArchWiki account nor a forum one, but as soon as I'll register I'll correct
the article.
Last thing: I discovered that my Bluetooth dongle is CSR 8510 A10 based so expect some ramblings about hid proxy.