The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 38,445β€…    Votes:  3β€…
Tag : sound  
Link: πŸ” See Original Answer on Ask Ubuntu ⧉ πŸ”—

URL: https://askubuntu.com/q/809849
Title: Ubuntu changes sound device after suspend, how to fix?
ID: /2016/08/09/Ubuntu-changes-sound-device-after-suspend_-how-to-fix_
Created: August 9, 2016    Edited:  June 12, 2020
Upload: September 15, 2024    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


Fixing PulseAudio switching off HDMI sound on Suspend

This β€œundocumented feature” appeared with Ubuntu 16.04 and new version of PulseAudio 8.

Create a new file /lib/systemd/system-sleep/tv-sound and copy in:

#!/bin/sh

case $1/$2 in
  pre/*)
    echo "Going to $2..."
    # Place your pre suspend commands here, or `exit 0`
    # if no pre suspend action required
    sleep 1
    ;;
  post/*)
    echo "Waking up from $2..."
    # Place your post suspend (resume) commands here, or `exit 0` 
    # if no post suspend action required
    sleep 2
    export PULSE_RUNTIME_PATH="/run/user/1000/pulse/"
    sudo -u rick -E pacmd set-card-profile 0 output:hdmi-stereo
    ;;
esac

NOTE: replace user name rick (third line from the bottom) with your user name.

Then mark it executable with the command:

sudo chmod +x /lib/systemd/system-sleep/tv-sound

An additional step might be required if output:hdmi-stereo (the device for most people) is different on your system.

⇧ Plugging network adapter in causes system to freeze