Skip to content

Instantly share code, notes, and snippets.

@vadimstasiev
Last active June 1, 2022 11:48
Show Gist options
  • Select an option

  • Save vadimstasiev/6bf25fb9155c05bc4ff852ed229653a6 to your computer and use it in GitHub Desktop.

Select an option

Save vadimstasiev/6bf25fb9155c05bc4ff852ed229653a6 to your computer and use it in GitHub Desktop.
Ubuntu 22 - sound not working after unplugging and re plugging line in
#!/bin/sh
case "$1" in
post)
DEVICE_ID=`lspci -D |grep Audio|awk '{print $1}'`
echo 1 > /sys/bus/pci/devices/${DEVICE_ID}/remove
sleep 1
echo 1 > /sys/bus/pci/rescan
alsa force-reload
systemctl --user restart pipewire-pulse wireplumber
esac

sudo mkdir /etc/acpi/actions

sudo nano /etc/acpi/actions/jack.sh

sudo chmod +x /etc/acpi/actions/jack.sh

#!/bin/bash
runuser -l $(id -nu 1000) -c 'killall pulseaudio'

sudo nano /etc/acpi/events/jack

event=jack/*
action=/etc/acpi/actions/jack.sh

or to be more specific:

event=jack[ /]line
action=/etc/acpi/actions/jack.sh

sudo /etc/init.d/acpid reload

another option

systemctl --user disable --now pipewire.socket
systemctl --user disable --now pipewire.service
systemctl --user restart pulseaudio.service
and adding this script in /lib/systemd/system-sleep/99_restart_sound :

sudo chmod +x /lib/systemd/system-sleep/99_restart_sound

@vadimstasiev
Copy link
Copy Markdown
Author

This may also fix sound problems: sudo alsactl restore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment