Skip to content

Instantly share code, notes, and snippets.

@eduardoaugustojulio
Created February 7, 2020 19:44
Show Gist options
  • Save eduardoaugustojulio/c5245493431cc6ab62b297912f67683b to your computer and use it in GitHub Desktop.
Save eduardoaugustojulio/c5245493431cc6ab62b297912f67683b 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
#!/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
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