LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Question for acid_kewpie regarding his hdmi audio script (https://www.linuxquestions.org/questions/linux-networking-3/question-for-acid_kewpie-regarding-his-hdmi-audio-script-926369/)

quasifilmie 01-29-2012 05:27 PM

Question for acid_kewpie regarding his hdmi audio script
 
Hi acid_kewpie,

I have a question regarding this thread you made a few months ago.

http://www.linuxquestions.org/questi...g-hdmi-903802/

I modify it a bit using trial and error and I am a bash noob. Where should I put this script? In other words I want the system to read and adhere to the rules in the script. :)

acid_kewpie 01-30-2012 02:32 AM

you'd have a file like /etc/udev/rules.d/hdmi.rules:

KERNEL=="card0", ACTION=="change", RUN+="/home/user/hdmi.sh"

But TBH, it never quite worked for me. I ended up converting into a script which I could run from a terminal without any parameters, which looked for the HDMI status and acted accordingly. I can post it later if you would find it useful.

quasifilmie 01-30-2012 02:35 PM

No that's okay. What I really need is an alsa conf file that causes the hdmi to automatically output audio instead of my laptop speakers like s/pdif. Anyway, I found a udev rule on the arch forums. Works for a couple arch users. Not for me. I made your script a sh file and added it to startup in gnome-session but all it did would override my sound settings and always cause hdmi output even if hdmi was not plugged in. KDE has phonon which allows you to choose prefence of device but I found it cumbersome and unstable.

acid_kewpie 01-30-2012 02:38 PM

ahh well I'm here now... someone else might be interested


Code:

#!/bin/sh

status="$(cat /sys/class/drm/card0-HDMI-A-1/status)"

export DISPLAY=:0.0

if [ "${status}" = disconnected ]
then
  xrandr --output HDMI1 --off
  pactl set-card-profile 0 output:analog-stereo+input:analog-stereo
elif [ "${status}" = connected ]
then
  xrandr --output HDMI1 --mode 1280x720 --right-of LVDS1
  pactl set-card-profile 0 output:hdmi-stereo+input:analog-stereo
fi



All times are GMT -5. The time now is 10:47 PM.