Comment 68 for bug 1438510

I've been using the script from #57 in 16.04 & 16.10, but in 17.04 I switched to GNOME and now the script fails since it cannot find an a2dp sink. After some research, it seems that the problem is with GDM starting its own pulseaudio process (https://bbs.archlinux.org/viewtopic.php?pid=1526658#p1526658). If you think you might have the same issue, first check your pulseaudio instances:

$ ps aux | grep pulseaudio
gdm 2578 4.3 0.1 2350536 12896 ? S<l 15:40 2:10 /usr/bin/pulseaudio --start --log-target=syslog
user 1533 4.3 0.1 2350536 12896 ? S<l 15:48 2:18 /usr/bin/pulseaudio --start --log-target=syslog

If you see a process owned by gdm, you can try to disable pulseaudio spawning by gdm during startup:

$ sudo nano /var/lib/gdm3/.config/pulse/client.conf
autospawn = no
daemon-binary = /bin/true

$ sudo chown gdm:gdm /var/lib/gdm3/.config/pulse/client.conf

Restart and #57 should now work.