The Cookie Machine - Click here to drag window

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

Views: 2,019β€…    Votes:  3β€…    βœ… Solution
Tags: sound   suspend   hdmi   kodi  
Link: πŸ” See Original Answer on Ask Ubuntu πŸ”—

URL: https://askubuntu.com/q/840543
Title: Ubuntu changing default audio output after suspend
ID: /2016/10/22/Ubuntu-changing-default-audio-output-after-suspend
Created: October 22, 2016    Edited:  June 12, 2020
Upload: November 24, 2022    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


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.

⇧ Commandline shortcut for current directory similar to ~ for home directory? I need some help understanding this bash script  β‡©