#!/bin/sh

case "$1" in
	Monitor)
		xrandr --screen 0 --output DVI-1 --set audio on
		xrandr --screen 1 --output DVI-0 --auto --set audio off
		;;
	AV)
		xrandr --screen 1 --output DVI-0 --auto --set audio on
		xrandr --screen 0 --output DVI-1 --set audio off
		;;
	*)
		if xrandr --screen 0 --props | fgrep -q "audio: on" ; then
			set -- Monitor
		else
			set -- AV
		fi
		;;
esac

case "$1" in
	Monitor)
		echo "<img>/usr/share/icons/gnome/scalable/status/network-receive-symbolic.svg</img>"
		echo "<tool>Audio: Monitor</tool>"
		echo "<click>$0 AV</click>"
		;;
	AV)
		echo "<img>/usr/share/icons/gnome/scalable/status/network-transmit-symbolic.svg</img>"
		echo "<tool>Audio: AV</tool>"
		echo "<click>$0 Monitor</click>"
		;;
esac
