Last active
August 1, 2022 23:31
-
-
Save rbobillot/497ad01631d96519a48ba9c5f0f3fa8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fixes a "no sound after sleep" bug on Ubuntu (20.04 and 22.04) | |
# | |
# After sleep (on my Mi Notebook laptop, for example), | |
# the sound doesn't work anymore on the main audio output (but still works through the jack cable) | |
# Running these commands will fix it | |
audio_restore() { | |
DEVICE_ID=`lspci -D |grep Audio|awk '{print $1}'` | |
sudo su - -c "echo 1 > '/sys/bus/pci/devices/${DEVICE_ID}/remove'" | |
sleep 0.5 | |
sudo su - -c "echo 1 > '/sys/bus/pci/rescan'" | |
sleep 0.5 | |
pactl set-sink-mute `pactl get-default-sink` 1 # mutes | |
pactl set-sink-mute `pactl get-default-sink` 0 # unmutes | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternatively, I can automate it:
sudo vim /lib/systemd/system-sleep/99_restart_sound
sudo chmod +x /lib/systemd/system-sleep/99_restart_sound
And then, after a sleep, I manually press the mute/unmute button