Bluetooth headphones headache in Linux: a trick with a2dp.py

If you ever used your bluetooth headphones in Linux you most likely noticed an annoying issue that the headphones are detected successfully, but the sound still not working correctly.

This problem has been discussed numerous times and I found recently a very useful post that helps to address the problem.

It seems like the solution is pretty easy – simply download the script a2dp.py from github and execute it using command line like so:

./a2dp.py

I noticed, however, that this does not always help and a2dp needs to be executed one more time for the headphones to work. In order to address the problem one may simply create a tiny script that will execute ./a2dp.py until it resolves the problem:

#!/bin/bash

keyword='"Enjoy" the HiFi stereo music :)'

while :
do
  result=$(./a2dp.py | grep "$keyword")
  if [ "$keyword" == "$result" ]
  then
    echo "correct - $result"
    break 
  fi
  echo "wrong - $result"
done

Update: I’ve created a small project on github to host this script: https://github.com/vshcherbyna/looping-a2dp

215 views

3 Comments

  1. Hello Abhilash Gupta,

    1. Go to https://github.com/vshcherbyna/looping-a2dp

    2. Click on the green button “Clone or download”

    3. Download zip

    4. Unzip the file

    5. Go to https://gist.github.com/pylover/d68be364adac5f946887b85e6ed6e7ae

    6. Click “Download ZIP”

    7. Save and unzip

    8. Now you have downloaded two zip files. Make sure that files a2dp.py and looping-a2dp.sh are in the same folder

    9. Connect your bluetooth headphones

    10. Once headphones connected, open terminal and navigate to the place where you stored the files

    11. Execute looping-a2dp.sh like so:

    .\looping-a2dp.sh

Leave a Reply

Your email address will not be published. Required fields are marked *

Identify yourself * Time limit is exhausted. Please reload CAPTCHA.