Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bluetooth keyboard for my HTPC. I pair it with my computer via bluetooth, and it works fine. However, when I turn off the keyboard or my computer, it has to connect again (which requires me entering a passcode on the computer and keyboard) when I turn them back on. I've looked through many forums and through that I have found that I'm missing some seemingly vital bluetooth files:




In the instructions that I've found online so far, I must change certain lines in any of these files. I am unable to, since they do not exist.

Am I missing a dependency or something? I've also tried installing Blueman but that didn't help at all.

I'm running Ubuntu 10.10 (Maverick).

Original post:

share|improve this question

This answer comes from a tutorial written by Andrew Martin on See the link below for the original post, however this is a complete rewrite. It is written specifically for an apple keyboard, however I have used it for multiple devices so it is not apple, or keyboard specific. Simply follow the instructions and you will have any bluetooth device auto connect in Ubuntu.

Go to System Settings > Bluetooth and follow the instructions to add your newly connected bluetooth device.

Follow the instructions and enter the pin when requested, then after the device is connected and working, power off the device. Now onto the auto connect part.

Open your terminal and enter the following commands:

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

The last command will display the output for your device such as:

    hci0    00:00:00:00:00:00

Install a new package to allow you to connect bluetooth via the command line.

$ 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:

$ hcitool scan        
Scanning ...
    AA:BB:CC:DD:EE:FF   Bluetooth Device Name
$ sudo hidd --connect AA:BB:CC:DD:EE:FF

Now we have to create a startup file to auto connect the device when the pc starts. Via the terminal...

$ gedit ~/

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

#! /bin/bash


while (sleep 1)
connected=`sudo hidd --show` > /dev/null
if [[ ! $connected =~ .*${address}.* ]] ; then
sudo hidd --connect ${address} > /dev/null 2>&1

Now create a new startup file. Substitute "keyboard" for whatever device name you choose. This is simply the name of the file.

$ sudo gedit /etc/init.d/keyboard

Paste the following, which tells your Ubuntu to run the file you just created at startup.

/home/username/ &

exit 0

Now set both files permissions to executable via the terminal.

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

Restart your computer and your device should auto connect and be working without you having to do anything.

I hope this helps a few people, it took me a long time to find a solution to my problem and I wanted to cement this tutorial a little deeper into the web.

The original link can be found here.

share|improve this answer
I believe that hidd is now deprecated as of bluez 4.0 in favour of udev, according to /usr/share/docs/bluez/NEWS.Debian.gz but I can't find any documentation on how to do it without bluez-compat. – tudor Jun 20 '13 at 5:18

I had a very similar issue with an Apple BlueTooth keyboard. I bought it because I loved the feeling of the keys. However, I could not keep it connected. The problem seemed to be in the keyboard identification. Once it was matched to an actual MAC computer, where it got an actual name, I no more had any issue with connecting it to Linux or Windows. My wife now uses it with no problem.

I don't know how this can be transposed in your situation, but this can be a starting point. From other friends, it seems that the device identification is the main issue here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.