I have a Microsoft Optical Desktop Elite Keyboard and Mouse for Bluetooth, and wanted to get them working on my newly installed Ubuntu 7.04 Feisty Fawn desktop. (This was my choice after the adventure of Windows Vista deciding it was not Genuine 1 1/2 months after install, even though it was.) See this article for the details.
I found the basics of this article on the Ubuntu forums, but found that I needed to adapt it a bit. So here is that article, with my changes/additions.
Getting Started
We need the MAC address (e.g. 00:00:00:00:00) of the mouse and keyboard. I shall use KEYBOARD_ADDR and MOUSE_ADDR as placeholders where you should put the addresses for the keyboard and mouse respectively.
Press the button on the mouse that makes it visible to be found by the computer. Do the same for the keyboard. Now open a terminal window and run the following command:
[email protected]:~$ hcitool scan
Scanning ...
KEYBOARD_ADDR Microsoft Wireless Keyboard
MOUSE_ADDR Microsoft Mouse
[email protected]:~$
Adding the Keyboard and Mouse
Now we need to add the keyboard and mouse to the bluetooth configuration files. Run the following command to pop up GEdit:
[email protected]:~$ sudo gedit /etc/bluetooth/hcid.conf
Note: You may be asked for your password, this is because we used sudo.
At the end of the file, add the following (replacing KEYBOARD_ADDR and MOUSE_ADDR for the keyboard and mouse MAC addresses as found earlier):
device KEYBOARD_ADDR {
name "Microsoft Wireless Keyboard";
auth enable;
encrypt enable;
}
device MOUSE_ADDR {
name "Microsoft Mouse";
}
Now you need to restart the bluetooth subsystem so that it refreshes it’s configuration file.
[email protected]:~$ sudo /etc/init.d/bluez-utils restart
* Restarting Bluetooth services... [ ok ]
If that doesn’t work you may need to use this line instead.
[email protected]:~$ sudo /etc/init.d/bluetooth restart
* Restarting Bluetooth services... [ ok ]
Pairing the Devices
You now need to pair the devices with the computer. Do not press any buttons on the keyboard as we’ll need to use it to enter a passcode so we can pair.
Run the following command:
[email protected]:~$ sudo hidd --search
Searching ...
Connecting to device MOUSE_ADDR
Connecting to device KEYBOARD_ADDR
[email protected]:~$
They could pair with the computer in any order, you will need to remember which one is the keyboard. As soon as Connecting to device KEYBOARD_ADDR appears you must enter a PIN code into the keyboard. It must consist of numbers not using the numpad, I can’t remember how many you can use, but somewhere between 4 and 8 should be fine. Type this number in to the keyboard and press Return.
A window should pop up on your computer asking you for the number you just entered on the keyboard.
You should now be set up. The devices should automatically reconnect when they go to sleep and when your computer boots up.
Troubleshooting
If you have followed all the steps above and you find your mouse or keyboard don’t automatically reconnect, we can fix it! I had to do this to get mine to work. Run the following command in a terminal:
[email protected]:~$ sudo gedit /etc/default/bluez-utils
If that doesn’t work, you may need to use this line instead.
[email protected]:~$ sudo gedit /etc/default/bluetooth
Find the lines with the following:
HIDD_ENABLED=0
HIDD_OPTIONS="..."
Change them to:
HIDD_ENABLED=1
HIDD_OPTIONS="--master --connect KEYBOARD_ADDR --connect MOUSE_ADDR --server"
Now reboot and hopefully they’ll automatically connect (give them a few seconds to connect after you move the mouse/press a key).
In Gutsy the Bluetooth tools are much better, but I did find that in order to connect to bluetooth mouse I needed to make sure gnome-vfs-obexftp was installed to use those tools.