-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·47 lines (39 loc) · 1.34 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·47 lines (39 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
# StreamMatrix Smart Launcher for Raspberry Pi
# Fallback XDG_RUNTIME_DIR if missing
if [ -z "$XDG_RUNTIME_DIR" ]; then
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
fi
# Auto-detect Wayland and X11 display socket if running from SSH or terminal without exported GUI vars
if [ -z "$WAYLAND_DISPLAY" ] && [ -S "$XDG_RUNTIME_DIR/wayland-0" ]; then
export WAYLAND_DISPLAY=wayland-0
fi
if [ -z "$DISPLAY" ]; then
if [ -S "/tmp/.X11-unix/X0" ]; then
export DISPLAY=:0
elif [ -n "$WAYLAND_DISPLAY" ]; then
export DISPLAY=:0
fi
fi
# Allow Qt to use Wayland or fallback to X11 (xcb) seamlessly
if [ -z "$QT_QPA_PLATFORM" ]; then
if [ -n "$WAYLAND_DISPLAY" ]; then
export QT_QPA_PLATFORM="wayland;xcb"
fi
fi
SCRIPT_SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SCRIPT_SOURCE" ]; do
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_SOURCE")" && pwd)"
SCRIPT_SOURCE="$(readlink "$SCRIPT_SOURCE")"
[[ $SCRIPT_SOURCE != /* ]] && SCRIPT_SOURCE="$SCRIPT_DIR/$SCRIPT_SOURCE"
done
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_SOURCE")" && pwd)"
BINARY="$SCRIPT_DIR/build/stream-matrix"
if [ ! -f "$BINARY" ] && [ -f "/usr/bin/stream-matrix" ]; then
BINARY="/usr/bin/stream-matrix"
fi
if [ ! -f "$BINARY" ]; then
echo "StreamMatrix binary not found at $BINARY. Please build first." >&2
exit 1
fi
exec "$BINARY" "$@"