#!/bin/sh

xrandr | grep -q "HDMI-1 connected"

if [ "$?" -eq "0" ]; then
    echo "Two screens available"

    MIRROR_FILE=~/.screenlayout/mirror-primary
    if [ -e "$MIRROR_FILE" ]; then
        echo "Mode set to mirror"
        rm "$MIRROR_FILE"
        ~/.screenlayout/twoscreens-mirror.sh
    else
        echo "Mode set to left-right"
        touch "$MIRROR_FILE"
        ~/.screenlayout/twoscreens.sh
    fi
else
    echo "Only one screen available"
    ~/.screenlayout/onescreen.sh
fi
