#!/bin/sh

CLASS="terminal"

while test $# -gt 0;do
    case $1 in
        -c|--class)
            shift
            CLASS=$1
            shift
            ;;
        *)
            break
            ;;
    esac
done

test "$1" = "-e" && shift
# {%@@ if terminal == "alacritty" @@%} #
    command -v alacritty > /dev/null &&
    {
        test $# -gt 0 &&
            exec alacritty --class "$CLASS" -e $@ ||
            exec alacritty --class "$CLASS"
    }
# {%@@ elif terminal == "foot" @@%} #
    if ! pidof foot; then
        foot --server 2> /dev/null &
    fi
    command -v footclient > /dev/null &&
        exec footclient --app-id "$CLASS" -- $@
# {%@@ elif terminal == "kitty" @@%} #
    command -v kitty > /dev/null &&
        exec kitty --class "$CLASS" -- $@
# {%@@ endif @@%} #

notify-send "Error" "Terminal program missing"
