#!/bin/sh

# First argument is the command
CMD="$1"
# Check that a command was provided
if [ -z "$CMD" ]; then
    echo "Error: no command provided."
    exit 1
fi
# Check if the command exists in PATH
if ! command -v "$CMD" >/dev/null 2>&1; then
    echo "Error: '$CMD' is not a valid command."
    exit 1
fi
# Everything is OK, launch cage
shift
cage -s -- /usr/libexec/cage/startkiosk "$CMD" "$@"
clear
sleep 1
echo "Back to $(tty)"
