Bluetooth_keyboard
This guide will explain how to set up the aluminum Apple keyboard with Gentoo Linux.
Contents |
The Keyboard
The keyboard automatically powers down when you’re not using it and turns on instantly as soon as you start typing. This intelligent power management means you’ll get up to nine months of battery life based on average usage patterns. It also has an on/off switch for when you’re away from your computer for a long time.
It takes 3 'AA' batteries.
To turn it on you just need to press the power button on the right hand side once. To turn it off press and hold the power button until the light goes off.
When the keyboard is off the green light is off, when the keyboard is on the green light is off. When the keyboard is ready to be connected, paired or used for the first time since being turned on and connected, the green light flashes.
Use flags
Make sure you have 'INPUT_DEVICES="keyboard mouse evdev"' in your '/etc/make.conf':
| File: /etc/make.conf |
... INPUT_DEVICES="keyboard mouse evdev" ... |
Installing BlueZ
I am assuming you already have a Linux compatible Bluetooth dongle. You first need to install BlueZ this provides Linux with the core Bluetooth layers and protocols.
# emerge net-wireless/bluez-libs # emerge net-wireless/bluez-utils
Then you need to start BlueZ and tell it to start on boot:
# /etc/init.d/bluetooth start # rc-update add bluetooth default
Configuring BlueZ
Turn your keyboard on, the green light should be flashing, then scan for it and note down its hardware address:
$ hcitool scan
You should get an output like this (where 'xx:xx:xx:xx:xx:xx' is your keyboards hardware address):
Scanning ... xx:xx:xx:xx:xx:xx Apple Wireless Keyboard
There are three configuration files you need to edit;
/etc/bluetooth/pin /etc/bluetooth/hcid.conf /etc/conf.d/bluetooth
Open '/etc/bluetooth/pin' with your favorite editor and enter 4 random numbers eg.
# nano /etc/bluetooth/pin
| File: /etc/bluetooth/pin |
1234 |
Open '/etc/bluetooth/hcid.conf' in your favorite editor and add the options specifically for your keyboard by adding the following stanza:
# nano /etc/bluetooth/hcid.conf
| File: /etc/bluetooth/hcid.conf |
}
device xx:xx:xx:xx:xx:xx {
name "Apple Wireless Keyboard";
auth enable;
encrypt enable;
}
|
Open '/etc/conf.d/bluetooth' in your favorite editor and make sure it contains these entries:
# nano /etc/conf.d/bluetooth
| File: /etc/conf.d/bluetooth |
# Start of hcid (allowed values are "true" and "false") HCID_ENABLE=true ... # Start hidd (allowed values are "true" and "false") HIDD_ENABLE=true # Arguments to hidd HIDD_OPTIONS="--connect xx:xx:xx:xx:xx:xx" ... |
That's it! Give BlueZ a restart and you should be ready to pair and use your shiny silver keyboard...
# /etc/init.d/bluetooth restart
Pairing
Restart the keyboard using the switch on the side (power off and on) to make it discoverable. Do not hit any keys on your Apple Keyboard unless this guide says so. It might cause all sorts of strange trouble during the pairing procedure. Right after restarting the keyboard, run the following command:
# hidd --connect xx:xx:xx:xx:xx:xx
hidd will now try to connect to the keyboard. Enter a 4 digit PIN and hit the enter key (both on your Apple Keyboard). Right after hitting enter, you will be asked by 'bluepin' for the PIN you just entered. Enter it (on your old keyboard). "hidd" should finish without further outputs. You should now be set up.
Using your keyboard
Turning the keyboard on before it has connected will cause the green light to flash. So if you turn it on as your computer is booting, this is normal. I find it will continue to flash until I use it for the first time (say on the login screen). However, if the keyboard stays in this state for too long you will need to restart it again before you can use it. Once it has been used there seems to be no problem with it coming in and out of sleep mode.
X11
Check to see if evdev is working with your keyboard and note its event no.
$ cat /proc/bus/input/devices
I: Bus=0005 Vendor=05ac Product=022d Version=0136 N: Name="PHYSICAL NAME OF YOUR KEYBOARD" P: Phys=xx:xx:xx:xx:xx:xx S: Sysfs=/class/input/input5 U: Uniq=xx:xx:xx:xx:xx:xx H: Handlers=kbd event5 B: EV=12001b B: KEY=10000 0 0 1 1007b00010007 ff9f217ac14057ff febeffdfffefffff fffffffffffffffe B: ABS=10000000000 B: MSC=10 B: LED=1f
You now need to amend you '/etc/X11/xorg.conf' file, use below as an example"
| File: /etc/X11/xorg.conf |
Section "ServerLayout"
...
InputDevice "Apple Inc. Keyboard" "SendCoreEvents"
...
EndSection
...
Section "InputDevice"
Identifier "Apple Inc. Keyboard"
Driver "evdev"
#Option "Device" "/dev/input/event7" # (cat /proc/bus/input/devices)
Option "Name" "Apple Inc. Keyboard" # (cat /proc/bus/input/devices)
Option "Phys" "xx:xx:xx:xx:xx:xx" # (cat /proc/bus/input/devices)
Option "XkbRules" "xorg"
Option "XkbModel" "macintosh"
Option "XkbLayout" "gb"
Option "XkbVariant" "mac"
EndSection
...
|
Number pad
Problem: your number pad isn't working.
Symptoms: enabling numlock doesn't enable the number pad, but converts the right half of the standard keys into a number pad.
This is a heavy-handed solution. It will enable the number pad unless you turn numlock on. Edit ~/.xmodmap as follows:
| File: $HOME/.xmodmap |
keycode 157 = KP_Equal keycode 79 = KP_7 keycode 80 = KP_8 keycode 81 = KP_9 keycode 82 = KP_Subtract keycode 83 = KP_4 keycode 84 = KP_5 keycode 85 = KP_6 keycode 86 = KP_Add keycode 87 = KP_1 keycode 88 = KP_2 keycode 89 = KP_3 keycode 90 = KP_0 keycode 91 = KP_Decimal |
This may not be necessary as of kernel version 2.6.27. Also, this was only tested with the wired version of the Apple aluminum keyboard; check xev if you're not sure about the keycodes.
KDE
KDEBluetooth
To give you a graphical representation of what your Bluetooth connections are up to you can install and run 'KDEBluetooth';
# emerge net-wireless/kdebluetooth $ kbluetoothd
When it is running you should see a Bluetooth icon in your panel. To finish configuring, right click and go to 'configuration' > 'Paired devices' > 'File location setup' and set the 'Link key file to '/var/lib/bluetooth/YOUR DONGLE'S HW ADDRESS/linkkeys'
Keyboard Layout
To setup the correct keyboard layout just load up the KDE control center, go to 'Regional & Accessibility' > 'Keyboard Layout'.
- Tick 'Enable keyboard layouts'
- Under 'Keyboard Model' choose 'Evdev-managed keyboard'
- Add your layout
- Click on your added layout and change the 'Layout variant' to 'mac'
To set up the correct keyboard shortcuts just load up the KDE control center, go to 'Regional & Accessibility' > 'Keyboard shortcuts'.
- choose the 'Mac Scheme'
Volume buttons
- Load kmix > Configure global shortcuts and set 'Increase', 'Decrease' and 'Mute' appropriately.
- Load Amarok > Configure global shortcuts and set 'Increase', 'Decrease' and 'Mute' to 'Command+F[appropriate].
Play/track buttons
- Load Amarok > Configure global shortcuts and set 'Play/Pause', 'Next Track' and 'Previous Track' to appropriate 'F' key
Troubleshooting
I found it would only connect when my USB dongle was in a specific USB port, even of the same chipset. My only guess is that it is a power issue.
Anyway, if strange things happen when you have connected, like repeated keys, or you can't connect. Try a different USB port and restart Bluetooth.
Created by NickStallman.net, Luxury Homes Australia
Real estate agents should be using interactive floor plans and real estate agent tools.

