#!/bin/sh

if [ "$1" = '-a' ]; then
    switch_audio='yes'
    video_mode="$2"
else
    video_mode="$1"
fi

case $video_mode in
    'lvds-hdmi2')
        xrandr \
            --output HDMI1 --mode 1280x720 --pos 0x0 --rotate normal \
            --output LVDS1 --primary --mode 1366x768 --pos 1368x0 --rotate normal \
            --output VIRTUAL1 --off \
            --output DP3 --off \
            --output DP2 --off \
            --output DP1 --off \
            --output HDMI3 --off \
            --output HDMI2 --off \
            --output VGA1 --off \

        if [ "$switch_audio" = 'yes' ]; then
            ponymix -c 0 set-profile output:hdmi-stereo
        fi
        ;;
    'hdmi2')
        xrandr \
            --output HDMI1 --primary --mode 1280x720 --pos 0x0 --rotate normal \
            --output LVDS1 --off \
            --output VIRTUAL1 --off \
            --output DP3 --off \
            --output DP2 --off \
            --output DP1 --off \
            --output HDMI3 --off \
            --output HDMI2 --off \
            --output VGA1 --off \

        if [ "$switch_audio" = 'yes' ]; then
            ponymix -c 0 set-profile output:hdmi-stereo
        fi
        ;;
    *)
        xrandr \
            --output LVDS1 --primary --mode 1366x768 --pos 1368x0 --rotate normal \
            --output HDMI1 --off \
            --output VIRTUAL1 --off \
            --output DP3 --off \
            --output DP2 --off \
            --output DP1 --off \
            --output HDMI3 --off \
            --output HDMI2 --off \
            --output VGA1 --off \

        ponymix -c 0 set-profile output:analog-stereo
        ;;
esac
