Get mac address terminal linux11/16/2023 You must also have bluez-tools installed. To execute this script successfully you will need to set your MAC address or provide it when running the script. If ]Įcho "Device was connected, now disconnecting $DEVICE"Įcho -e "disconnect $MAC" | bluetoothctl > /dev/nullĮcho "Device was disconnected, now connecting $DEVICE"Įcho -e "connect $MAC" | bluetoothctl > /dev/null I used the MAC address in the question: #!/bin/bashĭEVICE=$(bt-device -l | grep $MAC | cut -d " " -f1-2) Here is the script that uses bluetoothctl to connect / disconnect. I created this bash script and placed it in a folder on my path so I can connect / disconnect from these headphones via the command line (and via a launcher I built). I had a similar situation with some headphones I own that I constantly swap between my computer and phone. I suppose that is just saying my bluetooth address and that it is turned on.Īs I said already, via the normal User Interface, I can see the speakers and I am connected to them, but through terminal I get nothing.Īctually it is quite funny that hcitool scan isn't finding anything since my speakers are connected and every time I run the command the sound from the speakers breaks for a couple of seconds. If I run hciconfig scan I get: hci0: Type: BR/EDR Bus: USBīD Address: 40:2C:F4:78:E8:69 ACL MTU: 1021:8 SCO MTU: 64:1 I want to make a small script so every time they are visible I would connect to them automatically.Īnd after a few seconds the process dies. Via the GUI I can see them normally and I am connected to them. I bought a set of bluetooth speakers and I'm trying to connect to them via terminal.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |