None


How to connect an Apple Bluetooth Keyboard to Ubuntu (Troubleshooting)

(0 votes, average 0 out of 5)

Note: This guide uses programs specific to Ubuntu 10.04 (Lucid Lynx) and newer. For older versions of Ubuntu, please refer to this Ubuntu Wiki page.

Sometimes the Ubuntu bluetooth stack can behave erratically and prevent you from connecting your Apple Bluetooth Keyboard (or other bluetooth device). The normal procedure for connecting your bluetooth keyboard involves the following steps:

First, make sure the bluetooth applet is running by looking for the bluetooth icon on your panel:

bluetooth-icon

If it is not running, press ALT+F2, enter bluetooth-applet in the dialog box, and click Run to start it:

bluetooth-applet-run

 

Second, click on the icon and select the "Set up new device..." link. This will bring up a window which gives you some instructions. Click Forward and then select your Apple Bluetooth Keyboard. Note: your keyboard must be turned on during this step:

bluetooth-applet

 

Proceed through the installer, entering the PIN that it gives you on the keyboard and hitting the Enter key when done. If all goes well, your keyboard should start working shortly thereafter. If it does not work, or you receive messages on the computer telling you to enter the PIN from the device, you will need to perform additional steps. Power off your keyboard and then open the Terminal program (gnome-terminal) and enter the following commands:

1
2
3
$ killall bluetooth-applet
$ sudo /etc/init.d/bluetooth restart
$ sudo hcitool dev

The last command should return output for your device, something like the following:

Devices:
	hci0	00:00:00:00:00:00

Once this is done, you will need to install a new package to allow you to connect to the device via the command line. To do so, enter the following command:

$ sudo apt-get install bluez-compat

Once this has completed, you will now have hidd program installed. At this point, turn on your keyboard and enter the following command. It will output the MAC Address of your keyboard, which you will need to copy and paste into the subsequent command, as seen below:

1
2
3
4
$ hcitool scan        
Scanning ...
	AA:BB:CC:DD:EE:FF	Apple Wireless Keyboard
$ sudo hidd --connect AA:BB:CC:DD:EE:FF

Give it a couple seconds and then try typing on your keyboard. Hopefully, it will now be connected and working. To automate this process so your keyboard will connect automatically when you start your computer, create a new file by running this command:

$ gedit ~/.keyboard.sh

Enter the following text, substituting AA:BB:CC:DD:EE:FF with the hardware ID you saw above. Finally, save the file.

1
2
3
4
5
6
7
8
9
10
11
#! /bin/bash
 
address="AA:BB:CC:DD:EE:FF"
 
while (sleep 1)
do
 connected=`sudo hidd --show` > /dev/null
 if [[ ! $connected =~ .*${address}.* ]] ; then
  sudo hidd --connect ${address} > /dev/null 2>&1
 fi
done

 

Then, create a new startup file:

$ sudo gedit /etc/init.d/keyboard

 

Paste the following into this file, which tells it to run the file that you just created at startup. Note, you must specify the entire path to your home directory. In this example, the username used is ubuntu:

1
2
3
4
#!/bin/sh
/home/ubuntu/.keyboard.sh &
 
exit 0


Now, set both files to be executable and then add the startup file to the list of startup programs:

1
2
3
$ sudo chmod +x /etc/init.d/keyboard
$ chmod +x ~/.keyboard.sh
$ sudo update-rc.d keyboard defaults

Restart your computer and your keyboard should work immediately! If not, please post a question here or at Ubuntu Forums for more troubleshooting.

Partner Links:
Last Updated on Thursday, 28 October 2010 02:05  
Related Articles

» How to Install an Updated Driver For NVIDIA Graphics Cards

Whether you are putting a new graphics card into your computer or just want to update the driver, it is recommended that you visit the Manufacturers website. Here you will receive the latest update that will include many enhancements and improvements. Follow these steps to install the latest driver on your computer:Make sure your graphics card is installed or recognized by the system.Open up a web browser, like Internet Explorer, Mozilla Firefox, or Google Chrome, and visit...

» SQL SELECT DISTINCT Statement

To select information from a database without listing duplicates in the same column, use the SELECT DISTINCT statement in SQL. Syntax: 1SELECT DISTINCT <column name(s)> FROM <table name> For the column name(s) field, enter the names of the columns you would like to pull the distinct data from in the table.For the table name, enter the name of the table from which you are accessing the data. Examples:Suppose we have the following dataset in our database within a table...

» How to Unpack a Tarball (.tgz, tar.gz, or tar.bz2)

Unpacking a tarball through the command line is a simple a matter of memorization.  Here is the command to unpack a .tgz or .tar.gz file:tar -xzf To unpack tar.bz2 files, simply change the z to a j:tar -xjf Upon running one of these commands you should see an extracted version of the directory without the .tar.gz or .tgz extension.