-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenbox-native.sh
More file actions
executable file
·48 lines (43 loc) · 1.61 KB
/
Copy pathopenbox-native.sh
File metadata and controls
executable file
·48 lines (43 loc) · 1.61 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
48
#!/bin/bash
# Native host launcher. Runs the WebKitGTK host, which spawns the Python web
# server and renders the one UI in a native window.
set -euo pipefail
# Resolve the share dir. Works from the repo (script and app files colocated),
# from a Makefile/Flatpak install (script in $BINDIR, app files in
# $SHAREDIR/openbox), and inside the AppImage ($APPDIR).
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
if [ -n "${APPDIR:-}" ]; then
SHARE="$APPDIR/usr/share/openbox"
else
SHARE="$SCRIPT_DIR"
for candidate in "$SCRIPT_DIR" "$SCRIPT_DIR/../share/openbox" "/usr/local/share/openbox"; do
if [ -f "$candidate/web_app.py" ]; then
SHARE="$candidate"
break
fi
done
fi
HOST_BIN="${OPENBOX_NATIVE_HOST:-$SHARE/native_host}"
run_web_app()
{
if [ -n "${OPENBOX_BUNDLED_LIB_PATH:-}" ]; then
exec env LD_LIBRARY_PATH="$OPENBOX_BUNDLED_LIB_PATH" "${OPENBOX_PYTHON:-python3}" "$SHARE/web_app.py" "$@"
else
exec "${OPENBOX_PYTHON:-python3}" "$SHARE/web_app.py" "$@"
fi
}
if [ ! -x "$HOST_BIN" ]; then
echo "native_host is missing at $HOST_BIN; falling back to the system-browser app window." >&2
run_web_app "$@"
fi
export OPENBOX_WEB_APP="$SHARE/web_app.py"
export OPENBOX_PYTHON="${OPENBOX_PYTHON:-python3}"
if [ -n "${OPENBOX_BUNDLED_LIB_PATH:-}" ]; then
env LD_LIBRARY_PATH="$OPENBOX_BUNDLED_LIB_PATH" "$HOST_BIN" "$@" && exit 0
else
"$HOST_BIN" "$@" && exit 0
fi
code=$?
echo "native_host failed (exit $code). Install webkit2gtk: libwebkit2gtk-4.1-dev on Debian/Ubuntu, webkit2gtk-4.1 on Fedora." >&2
echo "Falling back to the system-browser app window." >&2
run_web_app "$@"