#!/bin/sh
# Starts OpenSoar on Sailfish OS together with the GPS->NMEA bridge.

DIR=/usr/libexec/opensoar

# Wayland setup (already set when started from the app grid, needed over SSH)
[ -n "$XDG_RUNTIME_DIR" ] || export XDG_RUNTIME_DIR=/run/user/$(id -u)
[ -d "$XDG_RUNTIME_DIR" ] || export XDG_RUNTIME_DIR=/tmp
[ -n "$WAYLAND_DISPLAY" ] || export WAYLAND_DISPLAY=/run/display/wayland-0
export SDL_VIDEODRIVER=wayland

"$DIR/gps2nmea" 10110 &
BRIDGE=$!
trap 'kill $BRIDGE 2>/dev/null' EXIT INT TERM

"$DIR/OpenSoar" "$@"
