TODO
Created
February 7, 2020 19:44
-
-
Save eduardoaugustojulio/9d332e6b950427c4a5dd5d1c707d92fc to your computer and use it in GitHub Desktop.
A simple script thats change the HDMI audio output via udev when detects it's plugged
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
readonly HDMI_STATUS="/sys/class/drm/card0/*HDMI*/status" | |
readonly HDMI_DISCONNECTED=$( grep -oq "disconnected" $HDMI_STATUS ) | |
change_sink() | |
{ | |
local stream="$1" | |
local stream_id="$( echo "$stream" | cut -f1 )" | |
local stream_name="$( echo "$stream" | cut -f2 )" | |
} | |
if $HDMI_DISCONNECTED ; then | |
zenity --notification --text "HDMI port removed" | |
change_sink "$( pactl list short sinks | grep "analog" )" | |
else | |
zenity --notification --text "HDMI port detected" | |
change_sink "$( pactl list short sinks | grep "hdmi" )" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SUBSYSTEM=="drm", ACTION=="change", RUN+="99-hdmi.audio.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment