The command is working so far as expected.
During a session i activate my bluetooth headset -> notebook with enabled bluetooth connects
After disabling my bluetooth headset the notebook falls back to build in audio device but not to hdmi audio (my default -> audio conn to hdmi monitor)
a default.pa can't be found but exist in /etc/pulse/...
If i set manually or by command see above my default sink to hdmi it also survive a reboot all good so far.
Only the "fallback to hdmi audio after using bluetooth" during a running session will not work as expected.
after disabling headset my f5cc....-default-sink still shows
bluez_sink.50_C2_75_E6_AD_3B.a2dp_sink
I added the following to my /etc/pulse/default.pa
### Make some devices default
set-default-sink output alsa_output.pci-0000_00_03.0.hdmi-stereo-extra2
set-default-source alsa_output.pci-0000_00_03.0.hdmi-stereo-extra2
-> corresponding to this
but this does not solve the prob because my ~/.config/pulse/***-default-sink is not set propperly back to
I am really not sure on this one. The default.pa in /etc/pulse should work.
You might try creating a udev rule with a script, instead. This will then manage disconnecting from headphones to redirect to HDMI sound output.
Create new document in your home directory and name it.
For this example, I will name it hdmi-sound.sh.
Open the file with text editor and paste in:
I configured the missing files as described and tested the *.sh if it does it's job - ok no errors and the ~/.config/pulse/**-default-sink switches (back) to hadmi audio.
I rebooted (weather nescessary or not) and tried to activate my bt headset (ok - as before) then turned it off ... waited a couple of seconds but the default-sink stays switched to bluez_sink.50_C2_75_E6_AD_3B.a2dp_sink
After several seconds i triggered the hdmi-sound.sh manual by terminal and after 3-4 seconds my default-sink was back on hdmi.
So the script work so far but does not be triggered automatically by the mechanism of switching on / off my bt headset.
It is a Jabra in Ear that switches of when i set the headset into its charging box.
The Bt Icon of ZorinOS disappear in the same moment i close the charging box.
Any further ideas?
Update:
i looked at my logs journalctl -a | grep udevd
and see entries like Okt 18 13:25:44 pc121 systemd-udevd[6758]: hci0:256: Process '/home/$USER/.config/pulse/hdmi-fallback.sh' failed with exit code 1.
the file "hdmi-fallback.sh" has following rights -rwxrwxr-x 1 $USER $USERGROUP 83 Okt 18 12:29 hdmi-fallback.sh
and i can run it from user terminal without errors.
setting the rights of hdmi-fallback.sh to $USER:root delivers same errors...
So the udev rule 99... is triggered but the RUN command fails...
Any ideas what causes udev to throw these errors?
I tried to run the script from a sudo shell (sudo su) # /home/$USER/.config/pulse/hdmi-fallback.sh
or # sudo -u $USER /home/$USER/.config/pulse/hdmi-fallback.sh
always delivers an error Es läuft kein PulseAudio-Dienst oder nicht als Sitzungsdienst.
(no pulseaudio service running nor as session service)
So the udev rules run as system service? -> then the exit code 1 maybe reference to the circumstance that the ENV system service is unlike user context...
So i don't know how to tell udev to run the script as $USER instead of system service?
As mentioned above same script running in $USER shell works as expected!
The clue is that (as i guessed udev is always running in "root / sudo" mode)
So the udev "user" can not connect to the pulseaudio socket of the actual user.
Following helped me to get out of this cage
#!/bin/bash
sleep 2 # wait for the headset to fully disconnect
sudo -u '#1000' XDG_RUNTIME_DIR=/run/user/1000 \
pacmd set-default-sink alsa_output.pci-0000_00_03.0.hdmi-stereo-extra2
You can find the solution here:
Now the udev rule is no longer producing exit code 1 messages and the switch is working. The change cost a little time, therefor the sleep time is really nescessary in my case.