130 lines of bash to connect my headphones

BlueZ says "Connected: yes", no sound comes out. The bash script that escalates until Bluetooth headphones actually produce an audio sink.