#!/usr/bin/bash

if command -v /usr/bin/ptyxis > /dev/null; then
  if [[ -z "$@" ]]; then
    /usr/bin/ptyxis --new-window
  else
    /usr/bin/ptyxis -- "$@"
  fi
elif grep '^org\.gnome\.Ptyxis$' <<< $(/usr/bin/flatpak list --app --columns=application); then
  if [[ -z "$@" ]]; then
    /usr/bin/flatpak run org.gnome.Ptyxis --new-window
  else
    /usr/bin/flatpak run org.gnome.Ptyxis -- "$@"
  fi
else
  /usr/bin/gnome-terminal -- "$@"
fi
