#!/bin/sh

function list_layouts () {
    autorandr 2>&1 | awk -e '{print $1}'
    echo "*create*"
    echo "*name-it*"
}


if [[ -e $(which rofi) ]] ; then
    LAYOUT=$(list_layouts | rofi -dmenu -p layout)
else
    LAYOUT=$(list_layouts | dmenu -p layout)
fi

if [[ $LAYOUT == "" ]] ; then
    echo Nothing to do.
elif [[ $LAYOUT == "*create*" ]] ; then
    arandr
elif [[ $LAYOUT == "*name-it*" ]] ; then
    NAME=$(rofi -dmenu -p 'name')
    autorandr -s ${NAME}
else
    autorandr -l $LAYOUT
fi
