I have a Sony WH-1000XM3 blue tooth headset. Every time I turn it on the microphone is set to "Internal". This is my laptop microphone which is awful. Now I manually go and change the the input device to "Headset WH-1000XM3", and everything works, but this manual process is tedious.
Audio settings:
Now I have a command which does the switching correctly:
pactl set-card-profile bluez_card.94_DB_56_19_07_F9 handsfree_head_unit
I have plugged this command into a script triggered by udev when the headset connects:
#!/bin/bashsleep 10 # wait for the headset to fully connect pactl set-card-profile bluez_card.94_DB_56_19_07_F9 handsfree_head_unit &>> /tmp/pactl-log
but I get the following error:
$ cat /tmp/pactl-logConnection failure: Connection refusedpa_context_connect() failed: Connection refused
I tried switching the user in the script with sudo -u myuserid pactl...
but I get the same error.