+# check for headless mode
+HEADLESS=0
+GUI=0
+HELP=0
+DEBUG=0
+for ARG in "${@}"; do
+ case "${ARG}" in
+ "--headless")
+ HEADLESS=1
+ ;;
+ "--help")
+ HELP=1
+ ;;
+ --help-*)
+ HELP=1
+ ;;
+ "--gui")
+ GUI=1
+ ;;
+ "--debug")
+ DEBUG=1
+ ;;
+ esac
+
+ if [ "${HELP}" = 1 ]; then
+ # --help takes precedence
+ HEADLESS=1
+ GUI=0
+ elif [ "${GUI}" = 1 ]; then
+ # --gui takes precedence over --headless
+ HEADLESS=0
+ fi
+done
+