2

On my laptop i'm running kodi connected to my tv with HDMI.

After suspending and resuming it my audio doesn't come out of the TV anymore but out of the laptops speakers. I've read multiple posts on how to set the default audio output after wakeup but it doesn't seem to work. Anybody knows how to fix this?

2 Answers 2

3

Fixing PulseAudio switching from TV to Laptop 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.

2
  • Thank you i've tried alot of scripts but this one worked! Thank you very mutch.
    – Cyber_Star
    Oct 23, 2016 at 15:15
  • My pleasure. Although the bug wasn't a show stopper, it was a pain to always have to reset sound to TV after resuming from suspend. It was driving me batty until I found the solution. Oct 23, 2016 at 15:29
0

I have the same problem. I tried tv-sound in /lib/systemd/system-sleep solution and that didn't work for me. I tried pacmd set-card-profile 0 output:hdmi-stereo from the user command line, and that didn't work for me.

What did work strangely enough, was opening sound settings under the speaker control. I didn't change anything, just the act of opening the settings caused the HDMI sound to recover. It isn't automatic, but it doesn't force me to reboot.

I did a pacmd dump before and after opening the settings window and there was no difference in the output.

As a side note, the 1000 in /run/user/1000/pulse is the user ID and needs to match the user name. When I was trying the solution I was logged into my wife's account which has a user ID of 1001.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.