From fdd36d3a2ed01a15e9345620305da57744dc22eb Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 20 Oct 2016 22:47:15 +0200 Subject: [PATCH] Add os/arch/apple-keyboard-bt --- os/arch/apple-keyboard-bt/README.md | 20 ++++++++++++++++++++ os/arch/apple-keyboard-bt/btkbd.conf | 3 +++ os/arch/apple-keyboard-bt/btkbd.service | 19 +++++++++++++++++++ os/arch/apple-keyboard-bt/install | 12 ++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 os/arch/apple-keyboard-bt/README.md create mode 100644 os/arch/apple-keyboard-bt/btkbd.conf create mode 100644 os/arch/apple-keyboard-bt/btkbd.service create mode 100755 os/arch/apple-keyboard-bt/install diff --git a/os/arch/apple-keyboard-bt/README.md b/os/arch/apple-keyboard-bt/README.md new file mode 100644 index 00000000..24443269 --- /dev/null +++ b/os/arch/apple-keyboard-bt/README.md @@ -0,0 +1,20 @@ +# Apple Keyboard auto connecting service + +The btkbd service auto-connects the wireless Apple Keyboard to Arch Linux. + +The keyboard must be paired and trusted before the btkbd service will work: + +``` +$ bluetoothctl -a +[bluetooth]# power on +[bluetooth]# agent KeyboardOnly +[bluetooth]# default-agent +[bluetooth]# pairable on +[bluetooth]# scan on +[bluetooth]# pair +[bluetooth]# trust +[bluetooth]# connect +[bluetooth]# quit +``` + +Then run `./install` to set up the service. diff --git a/os/arch/apple-keyboard-bt/btkbd.conf b/os/arch/apple-keyboard-bt/btkbd.conf new file mode 100644 index 00000000..08a51222 --- /dev/null +++ b/os/arch/apple-keyboard-bt/btkbd.conf @@ -0,0 +1,3 @@ +# Config file for btkbd.service +BTKBDMAC = ''00:25:BC:FA:22:C0'' +HCIDEVICE = 'hci0' diff --git a/os/arch/apple-keyboard-bt/btkbd.service b/os/arch/apple-keyboard-bt/btkbd.service new file mode 100644 index 00000000..71b3c4d3 --- /dev/null +++ b/os/arch/apple-keyboard-bt/btkbd.service @@ -0,0 +1,19 @@ +[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 diff --git a/os/arch/apple-keyboard-bt/install b/os/arch/apple-keyboard-bt/install new file mode 100755 index 00000000..9733c9a7 --- /dev/null +++ b/os/arch/apple-keyboard-bt/install @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Bluetooth +sudo ln -s $PWD/services/btkbd.conf /etc/ +sudo ln -s $PWD/services/btkbd.service /etc/systemd/system/ + +# Install service +sudo systemctl enable btkbd.service +sudo systemctl start btkbd.service + +# Turn off FN mode +bash -c 'echo 2 > /sys/module/hid_apple/parameters/fnmode'