pulseaudio auto switch output from HDMI
Created on:
123
  1. # /etc/acpi/events/hdmi-audio-switch
  2. event=jack/lineout
  3. action=/etc/acpi/hdmi-audio.sh %e
/etcacpihdmi-audio.sh 870 B (text/x-shellscript)
12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. set -e -u -x
  3. # /etc/acpi/hdmi-audio.sh
  4. # Source: https://unix.stackexchange.com/questions/342556/pulseaudio-auto-switch-sink-when-headphones-connected
  5. # Needed: git clone https://www.tablix.org/~avian/git/paswitch.git
  6. # Use acpi_listen as root to get jack/thing THING infos
  7. # For debugging purposes
  8. #exec 1> /tmp/prout.log 2>&1
  9. if [ "$1" = "jack/lineout" -a "$2" = "LINEOUT" ]; then
  10. case "$3" in
  11. plug)
  12. sink=alsa_output.pci-0000_00_03.0.hdmi-stereo
  13. ;;
  14. *)
  15. sink=alsa_output.pci-0000_00_1b.0.analog-stereo
  16. ;;
  17. esac
  18. for userdir in /run/user/*; do
  19. uid="$(basename $userdir)"
  20. user="$(id -un $uid)"
  21. if [ -f "$userdir/pulse/pid" ]; then
  22. PULSE_RUNTIME_PATH="$userdir/pulse" su "$user" -c "paswitch $sink"
  23. fi
  24. done
  25. fi
© 2017-2018 git.txt - version: 0.5.2 - b28934a7ddecd31f2e40cb7058fa1fb5e9a1acc8 - page: 113ms - template: 3ms
Gitxts: 43, managed: 90
Sources - Go1.11.5