This article describes how to set up a Bluetooth mouse through the command line without relying upon a graphical application.
Install the Bluetooth for more information.package which contains the current Linux bluetooth stack (Bluez5). You may also want to install which provides the bluetoothctl utility. See
Bluez5 provides the bluetoothctl utility which provides a simple interface for configuring bluetooth devices.
The text below is an example of how you can connect a bluetooth mouse using bluetoothctl:
# bluetoothctl [bluetooth]# list Controller <controller mac> BlueZ 5.5 [default] [bluetooth]# select <controller mac> [bluetooth]# power on [bluetooth]# scan on [bluetooth]# agent on [bluetooth]# devices Device <mouse mac> Name: Bluetooth Mouse [bluetooth]# pair <mouse mac> [bluetooth]# trust <mouse mac> [bluetooth]# connect <mouse mac>
No additional actions are necessary if the bluetooth service is started using systemd. If it does not work try the following command:
# modprobe -v btusb bluetooth hidp l2cap
It loads the kernel modules you need, if they were not loaded automatically.
The following command should show your bluetooth adapter:
hci0: Type: BR/EDR Bus: USB BD Address: 00:22:43:E1:82:E0 ACL MTU: 1021:8 SCO MTU: 64:1 UP RUNNING PSCAN RX bytes:1062273 acl:62061 sco:0 events:778 errors:0 TX bytes:1825 acl:11 sco:0 commands:39 errors:0
Configure bluetooth mouse
The method described here is based in three steps, in this order:
- Make the PC learn about the bluetooth mouse.
- Grant the mouse permissions to connect.
- Make the mouse learn about the PC.
Search your mouse
First make your mouse discoverable. For example some mouse need to press a button. Then issue the following command:
# hcitool scan
Scanning ... 00:07:61:F5:5C:3D Logitech Bluetooth Mouse M555b
Your mouse bluetooth mac address will be similar to
12:34:56:78:9A:BC. You may also find it in the documentation or on the mouse itself.
Connecting the mouse
To scan the device (you may need to use
su -c or
hidd --search hcitool inq
To connect the device:
hidd --connect <bdaddr>
To show your currently connected devices:
The mouse should show up in this list. If it does not, press the reset button to make it discoverable.
Connecting the mouse at startup
# Arguments to hidd HIDD_OPTIONS="--connect <enter here your bluetooth mouse mac address>"
and test the new settings:
/etc/rc.d/bluetooth stop hidd --killall #(drop mouse connection) /etc/rc.d/bluetooth start
If you are using an older version, then to start the mouse at startup, add:
hidd --connect <enter here your bluetooth mouse address (No capitals!!!)>
If you experience mouse lag you can try to increase the polling rate. See Mouse polling rate for more information.
Problems with the USB dongle
If you have trouble with your USB dongle, you may also want to try:
# modprobe -v rfcomm
At this point, you should get an hci0 device with:
# hcitool dev
Sometimes the device is not active right away. Try starting the interface with:
# hciconfig hci0 up
and searching for devices as shown above.