#!/bin/sh
# 从「应用程序菜单 / Finder」双击启动：自动找到可用终端模拟器并打开 QL 终端。
QL_HOME="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
CMD="'$QL_HOME/bin/ql' --terminal; exec sh"
if command -v gnome-terminal >/dev/null 2>&1; then
  gnome-terminal -- bash -lc "$CMD"
elif command -v konsole >/dev/null 2>&1; then
  konsole -e bash -lc "$CMD"
elif command -v xfce4-terminal >/dev/null 2>&1; then
  xfce4-terminal -e "bash -lc '$CMD'"
elif command -v xterm >/dev/null 2>&1; then
  xterm -e sh -lc "$CMD"
else
  echo "[QL] 未找到终端模拟器，请在当前终端直接运行: $QL_HOME/bin/ql" >&2
  exec sh -lc "$QL_HOME/bin/ql --terminal"
fi
