After updating to 20.04 I found that the headphone jack does not work as it should. So as workaround I thought of running a script on an acpi event. eg when headphone jack is plugged-in to reload the sound module. This is the script:
#!/bin/sh
#if [ -z "$1" ]; then
# echo "Pulseaudio has these cards:"
# pacmd list-cards | grep 'name: '
#fi
MODULE_INDEX=`pacmd list-modules | tac | grep -A 10 -e "argument: .*$1" | grep 'index:' | head -n 1 | cut -d ':' -f 2 | tr -d ' '`
MODULE_NAME=`pacmd list-modules | tac | grep -A 10 -e "argument: .*$1" | grep 'name:' | head -n 1 | cut -d ':' -f 2 | tr -d '<>'`
MODULE_ARGUMENTS=`pacmd list-modules | tac | grep -e "argument: .*$1" | head -n 1 | cut -d ':' -f 2 | tr -d '<>'`
#echo "Module index is $MODULE_INDEX"
#echo "Module name: $MODULE_NAME"
#echo "Module args: $MODULE_ARGUMENTS"
if [ -z "$MODULE_INDEX" ]; then echo "Could not find module index"; exit 0; fi
if [ -z "$MODULE_NAME" ]; then echo "Could not find module name"; exit 0; fi
if [ -z "$MODULE_ARGUMENTS" ]; then echo "Could not find module arguments"; exit 0; fi
#echo "Unloading module"
pacmd unload-module $MODULE_INDEX
#echo ""
#echo "Reloading module"
pacmd load-module $MODULE_NAME $MODULE_ARGUMENTS
#echo ""
This works fine if I run it manually.
So next I want to run it on the acpi event. Using acpi_listen when I plug in the jack I get
jack/headphone HEADPHONE plug
Next in /etc/acpi/events
I create file that contains
event=jack/headphone HEADPHONE plug
action=/etc/acpi/soundcard2.sh
I restart acpid with
sudo service acpid restart
(I even restarted the system) But when I plugin the headphone jack nothing happens. Am I doing something wrong ?
Thanks in advance
sudo chmod +x /etc/acpi/soundcard2.sh
. Here is one similar question that could be worth: How do I disable the touchpad when the lid is twisted or closed?