Hi,
Is there any general and clean way to switch the sound output to HDMI when a HDMI is plugged in?
I can write a bash script but a prefer a cleaner solution if possible.
Thanks!
Automatic sound switch to HDMI when plugged in
- Michael-IDA
- Posts: 359
- Joined: Sat Jan 12, 2019 8:00 pm
Re: Automatic sound switch to HDMI when plugged in
I'd like to be able to do this as well.
Following...
Following...
NIH Cancer Study: The group supplemented with both vitamins and fenbendazole exhibited significant (P = 0.009) inhibition of tumor growth.
The day Microsoft makes a product that doesn't suck...
... is the day they make a vacuum cleaner.
The day Microsoft makes a product that doesn't suck...
... is the day they make a vacuum cleaner.
Re: Automatic sound switch to HDMI when plugged in
I wrote this dirty but effective script and add it to a launcher in my upper panel. You have to check the "launch in terminal" to be able to see the messages. I just have to click on the launcher when I need to switch.
You may need to change some stuff depending on your profiles and outputs...
#!/bin/bash
actstereo=$(pacmd list |grep 'active profile' | grep 'output:analog-stereo+input:analog-stereo')
hdmiact=$(pacmd info | grep 'hdmi-output-1' | grep 'yes')
# Switch to Analog Stereo Duplex profile if another profile is active
if [[ -z $actstereo ]]; then
echo "Switch to Analog Stereo Duplex"
pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo
# If HDMI is available, switch to it
elif [[ -n $hdmiact ]]; then
echo "Switch to HDMI output"
pacmd set-card-profile 0 output:hdmi-stereo-extra1+input:analog-stereo
# Otherwise, stick to Analog Stereo Duplex
else
echo "Analog Stereo Duplex already active"
fi
sleep 1
You may need to change some stuff depending on your profiles and outputs...
#!/bin/bash
actstereo=$(pacmd list |grep 'active profile' | grep 'output:analog-stereo+input:analog-stereo')
hdmiact=$(pacmd info | grep 'hdmi-output-1' | grep 'yes')
# Switch to Analog Stereo Duplex profile if another profile is active
if [[ -z $actstereo ]]; then
echo "Switch to Analog Stereo Duplex"
pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo
# If HDMI is available, switch to it
elif [[ -n $hdmiact ]]; then
echo "Switch to HDMI output"
pacmd set-card-profile 0 output:hdmi-stereo-extra1+input:analog-stereo
# Otherwise, stick to Analog Stereo Duplex
else
echo "Analog Stereo Duplex already active"
fi
sleep 1
Re: Automatic sound switch to HDMI when plugged in
See the MX Wiki: https://mxlinux.org/wiki/hardware/sound-not-working/
For automatic switching to HDMI when connected, consult this GitHub script.
Please read the Forum Rules, How To Ask For Help, How to Break Your System and Don't Break Debian. Always include your full Quick System Info (QSI) with each and every new help request.