#!/usr/bin/env bash

modes="monitor-std
monitor-presenter"

host_mode_monitor () {
    echo "Loading portalo monitor layout ${1:-std}"
    yadm config --unset-all local.class monitor-*

    if [ -n "$1" ]; then
        yadm config --add local.class "$1"
    fi

    swaymsg reload
}

if [ -z "$1" ]; then
    mode=$(echo "$modes" | $DMENU -p "mode")
else 
    mode=$1
fi

case $mode in
    "monitor-std")  host_mode_monitor ;;
    "monitor-"*)    host_mode_monitor "$mode" ;;
    *)              echo "'$mode' is not a valid mode" ;;
esac