It is awesome when your wireless headphones automatically pairing with your system.
This daemon-script and commands will help you to solve this problem.
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
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
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