#!/bin/sh
# DualCPY launcher: run from a per-user data dir so the app's relative
# config/, logs/ and bin/ paths resolve to user-writable locations.
# The bundled scrcpy/adb in /opt/dualcpy/bin are picked up via PATH
# (user-installed binaries in ~/.local/share/dualcpy/bin still win).
DATA_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/dualcpy"
mkdir -p "$DATA_DIR/bin" "$DATA_DIR/config" "$DATA_DIR/logs"
cd "$DATA_DIR" || exit 1
PATH="/opt/dualcpy/bin:$PATH"
export PATH
if [ -z "$SCRCPY_SERVER_PATH" ] && [ -f /opt/dualcpy/bin/scrcpy-server ]; then
    SCRCPY_SERVER_PATH=/opt/dualcpy/bin/scrcpy-server
    export SCRCPY_SERVER_PATH
fi
exec /opt/dualcpy/DualCPY "$@"
