setmon (405B)
1 #!/bin/sh 2 3 PULSE_SERVER="unix:/run/user/$(id -u)/pulse/native" 4 5 main() { 6 dev="$(xrandr |awk '/ connected/ {print $1}' |sort |head -1)" 7 8 case $dev in 9 HDMI*) audio="hdmi";; 10 LVDS*) audio="analog";; 11 esac 12 13 sudo -u $(id -un) pactl --server $PULSE_SERVER \ 14 set-card-profile 0 \ 15 output:${audio}-stereo+input:analog-stereo 16 xrandr --output $dev --auto 17 18 echo "$dev w/ $audio audio." 19 } 20 21 main "$@"