#!/bin/bash
# This script configures any environment prerequisites needed by Google Earth.
LC_NUMERIC=en_US.UTF-8 # Start Google Earth using this script rather than googleearth-bin directly.

# If you want to use an external copy of GPSBabel, you can specify it here.
# if [[ -z "$GPSBABEL" ]]; then export GPSBABEL="$(which gpsbabel)"; fi

# If DISPLAY is not set, try to autodetect a value.
if [[ -z "$DISPLAY" ]]; then
  echo "WARNING: DISPLAY environment variable is not set."
  x_displays=(/tmp/.X11-unix/X*)
  display="${x_displays[0]}"
  if [[ -e "$display" ]]; then
    export DISPLAY=":${display/*X/}"
    echo "        Found ${display}; setting DISPLAY=\"${DISPLAY}\"."
  else
    echo "        X11 display not detected; Google Earth may not run correctly."
  fi
fi

LC_NUMERIC=en_US.UTF-8 "$(dirname "$(readlink -f "$0")")/googleearth-bin" "$@"
