Pair Bluetooth devices via the command line on Linux
On Linux, it is possible to do almost everything from the command line, and connecting to Bluetooth devices is no exception. As an i3wm user, using anything other than the command line to pair my Bluetooth devices would mean pulling in a ton of extra dependencies — and I don't want them.
Install the Bluetooth dependencies
If you use any distribution other than Arch, the package names may differ. Refer to your distro's documentation if you encounter any errors.
$ sudo pacman -S bluez bluez-utils
Start the Bluetooth daemon
$ sudo systemctl start bluetooth
Enable the Bluetooth daemon at boot
If you want Bluetooth to start automatically on boot, just enable the daemon.
$ sudo systemctl enable bluetooth
Pair and connect a Bluetooth device
$ bluetoothctl [bluetooth]# default-agent [bluetooth]# power on [bluetooth]# scan on [bluetooth]# pair DEVICE-MAC-ADDRESS [bluetooth]# trust DEVICE-MAC-ADDRESS [bluetooth]# connect DEVICE-MAC-ADDRESS [bluetooth]# scan off
TIP: You can use TAB to autocomplete the commands and the MAC addresses.