Warning: Undefined array key "2026-04" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2024-09" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2024-07" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2020-06" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2020-04" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2019-07" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2017-11" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2015-07" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2013-04" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2012-11" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2012-03" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2012-02" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2011-07" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2011-03" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2011-02" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2011-01" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2010-11" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2010-10" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2010-08" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2010-06" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2010-05" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2010-04" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2010-01" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2009-12" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Warning: Undefined array key "2009-11" in /home/brain4fr/public_html/brain4free.cyon.site/wiki/lib/plugins/blog/syntax/archive.php on line 194

Blog

Script to reconnect Bluetooth device in Linux

Example of a radio with iPod dock connector, now with Bluetooth receiver

Today I wasted several hours to write a small script that helps you to use a Bluetooth audio device with several Linux computers.

Problem: Several computers, one Bluetooth receiver

Our radio in the kitchen got upcycled with a Bluetooth receiver that fits into the obsolete 30 pin iPod dock connector. This receivers are cheap and easy and help lots of devices to get an interface to modern equipment.

Unfortunately our receiver can only handle one pairing, which means that every-time my girlfriend used the radio before me, I had to open the KDE bluedevil menu to delete, search and newly connect the device before I could listen to music in the kitchen (and vice versa). Time consuming and annoying.

Linux and Bluetooth

Bluetooth is a very common standard to connect phones and computers to audio devices like headphones and loudspeakers. But for Linux users Bluetooth is not the easiest thing and it's known to be not very well documented. OK, the Bluetooth standard changes more often than other technologies and the Linux Bluetooth tools improved as well, but also the tool names changed more then once and there was also the chance from pure ALSA to PulseAudio…

None of that helped me today to find a quick, simple solution for my small problem. I found numerous old guides for long gone tools and interfaces and the current Linux Bluetooth tools are not built to be run from scripts?!

Solution

OK, after many searches, try and errors and climbing up from the legacy tools to the more recent ones I managed to have a script that:

  • Deletes a connection to previously used Bluetooth device
  • Scans for Bluetooth devices
  • Creates a new connection incl. pairing to the deleted device.

connect-i-link.sh

#!/bin/bash

# remove old connection 
echo -e 'power on\ndisconnect EB:06:BF:0A:13:6F\nremove EB:06:BF:0A:13:6F\nquit' | bluetoothctl

# scan bluetooth devices for 20 s
timeout -k 20 15 bt-adapter --discover

# create a new pairing and connection
bt-device --connect EB:06:BF:0A:13:6F

# the command above does not connect audio, so do again a connection with bluetoothctl
echo -e 'trust EB:06:BF:0A:13:6F\nconnect EB:06:BF:0A:13:6F\ninfo EB:06:BF:0A:13:6F\nquit' | bluetoothctl

You have to replace the MAC address (EB:06:BF:0A:13:6F) in the script with the address of your device. You find this address in bluedevil or with bluetoothctl (command: scan on)

To get Bluetooth audio working in recent Linux distributions (> 2018) you have to install:

apt install bluez bluez-tools bluez-firmware pulseaudio-module-bluetooth
2020/04/15 23:44 · dogbert

Insel Mainau

Wir hatten Besuch und haben diese Gelegenheit genutzt um die Insel Mainau zu besuchen. Ich habe meine 3D Photoausrüstung mitgenommen und die besseren Photos habe ich vorhin online gestellt.

Zur Photogalerie: Insel Mainau

Insel Mainau, 3D, Orchidee

<< Newer entries | Older entries >>

Blog History

2009-11: 3 entries 2009-12: 1 entry 2010-01: 1 entry 2010-04: 1 entry 2010-05: 2 entries 2010-06: 1 entry 2010-08: 1 entry 2010-10: 1 entry 2010-11: 1 entry 2011-01: 1 entry 2011-02: 1 entry 2011-03: 2 entries 2011-07: 1 entry 2012-02: 1 entry 2012-03: 1 entry 2012-11: 1 entry 2013-04: 2 entries 2015-07: 3 entries 2017-11: 1 entry 2019-07: 1 entry 2020-04: 1 entry 2020-06: 1 entry 2024-07: 1 entry 2024-09: 1 entry 2026-04: 1 entry

2026

April

2024

September

July

2020

June

April

2019

July

2017

November

2015

July

2013

April

2012

November

March

February

2011

July

March

February

January

2010

November

October

August

June

May

April

January

2009

December

November

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International