Easier way to connect to Bluetooth device
Is there a way to connect to a USB device in fewer steps than this?
4 Answers 4
Take a look at a similar question/answer here.
First, the MAC Address of the Bluetooth device is needed. You can find it by running the following commands:
- sudo systemctl start bluetooth
- bluetoothctl (a new bash prompt «[bluetooth]#» will be visible after running this command)
- devices
- Look for the MAC Address of your Bluetooth device by searching through the names of the device listed, assuming the device is powered on and visible.
Finally, run the following commands which start the Bluetooth service and passes the commands through the echo program. These two commands are what you need to connect to your bluetooth device over the terminal.
- sudo systemctl start bluetooth
- echo -e ‘connect YOUR_DEVICE_MAC_ADDRESS \nquit’ | bluetoothctl
This can be put in a bash script and the bash script can be automated to run upon startup.
Just typing bluetoothctl was sufficient to find the MAC address (at least if the device is already connected). And echo «connect $DEVICE_MAC» | bluetoothctl was sufficient to establish a connection when not currently connected. So scripting it would work. Running the script on startup is not useful for me. But calling the script from a hotkey should work.
Though I didn’t use this answer exactly the way it was written. It still gave me the information I needed to create a hotkey to achieve the desired effect.
@kasperd Could you tell which command did you use exactly for the hotkey? I tried the mentioned command but it didn’t work for me.
In addition to the CLI-based solutions in other answers, there is a Gnome extension called Bluetooth quick connect which streamlines the GUI a lot. It adds a toggle button to the Bluetooth menu for each paired device, which cuts your number of clicks down to three.
The easiest way to install Gnome extensions is to first install the Gnome extensions manager ( apt install gnome-shell-extensions ) and the Firefox plugin (which will be linked at the top of the extension’s webpage). After that, installing any Gnome extension is just a case of clicking the toggle button at the top of the corresponding webpage.
How to Find Your MAC address in Ubuntu and Other Linux Distros
When you are learning networking or troubleshooting it, you would need to know the MAC address.
A computer can have more than one MAC address. It is because the MAC address is a core part of networking, and each networking peripheral device has its own MAC address.
So, your WiFi card has a MAC address, and so does the Ethernet (LAN) port. Even the Bluetooth has one.
The MAC address, also known as the physical address, is a 12-digit hexadecimal code (48-bits) and is represented as MM:MM:MM:SS:SS:SS
In this tutorial, I’ll share the steps for finding the MAC address of your desired networking interface in Linux. I’ll show both command line and GUI methods.
Method 1: Find MAC address using command line
There are serveral Linux networking commands that can be used to get the MAC address of the WiFi or LAN cards.
Open up your terminal and use the following command, and it will bring the address of the present network cards in your system:
And you’ll be met with the following output:
Generally, the wireless device names will be wlan0, wlan1, wlan2, wlo0, wlo1, and wlo2, whereas the Ethernet (wired device) will probably have eth0, eth1, eno0, eno1,enpls0, or enpls1.
You can find the MAC address of each device at the last line of the device description, followed by link/ether and it’s 52:54:00:5c:92:bf in my case.
Get the MAC address of Bluetooth
As I mentioned earlier, all networking devices have a physical address. If you want to see the MAC address of your Bluetooth adapter, you can use this command:
You can see it beside the BD Address field.
[email protected]:~$ hciconfig hci0: Type: Primary Bus: USB BD Address: DC:41:A9:FB:7A:C4 ACL MTU: 1021:4 SCO MTU: 96:6 UP RUNNING RX bytes:17895787 acl:275 sco:250783 events:298882 errors:0 TX bytes:303664302 acl:295384 sco:249895 commands:3380 errors:0
You can also use the bluetoothctl command here.
Method 2: Get MAC address using GUI
If you’re afraid of using the terminal you can use the network settings to get the MAC address details.
I am using Ubuntu with the GNOME desktop environment. If you use some other desktop environments, the screenshots may not look the same.
First, search for settings in the system menu and open the first result.
Now, for the left menu bar, select Network and click on the little gear icon located near to wired network toggle. Even if you’re not connected to a wired network, you can still follow the same approach.
If you’re on Wi-Fi, there will be an option for Wi-Fi in the left menu bar. From there, you have to follow the same approach (clicking on the gear icon) to get your MAC address.
Once you click on the gear icon, you’ll be met with details of the selected network interface. Here, the MAC address is given as the Hardware address.
Here you have it in the easiest way possible!
Final Words
Did you know that the first half of hexadecimal code (24 bits) is used to represent the manufacturer of your network adapter?
Finding a MAC address in Linux is quite easy as you have seen it here. On the same note, you may like to learn about changing the MAC address in Linux.
Let me know if you have any questions or suggestions.