Skip to content

🐧 Automatic connection to bluetooth headphones by mac address, like in an Apple's ecosystem. Uses as a service in linux or aliases.

License

Notifications You must be signed in to change notification settings

a1k0u/ubuntu-bluetooth-headphones-connect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automatically connection of bluetooth headphones in Ubuntu

It is awesome when your wireless headphones automatically pairing with your system.

This daemon-script and commands will help you to solve this problem.

Find out MAC-address of your headphones

If you have already connected your device, then use this command:

bluetoothctl paired-devices

In another case, you should use scan system (do not forget to turn on your device):

bluetoothctl scan on

Start daemon

Open headphones.service and fill in MAC-address:

nano headphones.service

Create folder for script and copy files:

sudo mkdir /opt/headphones-connect/
sudo cp headphones.sh /opt/headphones-connect/headphones.sh
sudo cp headphones.service /etc/systemd/system/headphones.service

Reload daemons, enable and start new service, try to check status of it:

sudo systemctl daemon-reload
sudo systemctl enable headphones 
sudo systemctl start headphones
sudo systemctl status headphones

CLI commands to manage your connection with headphones

Add aliases and environmental variable in .bashrc, but after adding MAC-address.

nano import-commands-bash.sh 
./import-commands-bash.sh

Connect headphones:

bluetoothctl power on && bluetoothctl connect $MAC_HEADPHONES

Disconnect headphones:

bluetoothctl disconnect $MAC_HEADPHONES && bluetoothctl power off

Remove headphones:

bluetoothctl untrust $MAC_HEADPHONES && bluetoothctl remove $MAC_HEADPHONES

Add headphones:

bluetoothctl trust $MAC_HEADPHONES

With this daemon you won't able connect your headphones with another device, but there is a solution: in infinity circle power off bluetooth, after press Ctrl+C to stop it.

while true; do bluetoothctl power off; done

About

🐧 Automatic connection to bluetooth headphones by mac address, like in an Apple's ecosystem. Uses as a service in linux or aliases.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages