AtlatestRepositorylantern
1
#!/usr/bin/env bash2
# Launch Slate in a native Lantern window with TRANSPARENCY on + REAL local3
# fs + pty access.4
#5
# ./run-slate.sh [slate-repo-dir | web-build-dir | URL] [extra lantern args...]6
#7
# Give it a path to a Slate REPO folder (the one holding build/web/index.html8
# after `sigil build`), a web build dir directly, or an http/https/file URL of a9
# hosted build (e.g. `sigil serve` — loaded directly, no local build / no cache).10
# Defaults to the sibling `slate` checkout. It resolves the11
# web build, wraps the run in an ephemeral `guix shell` (the GTK4 + WebKitGTK +12
# Mesa graphics stack from gl-manifest.scm — no persistent profile), and launches13
# with --transparent so the window is transparency-CAPABLE.14
#15
# Transparency is opt-in-safe: with Slate's own translucency OFF (the default) the16
# window looks completely normal; toggle Slate translucency ON (command palette:17
# "Transparency: on") and the desktop shows through the frosted content.18
#19
# If the window never maps, re-run with LANTERN_SOFTWARE_RENDER=1 (the Mesa GL20
# loader-path gotcha) — it is passed through to the child if set in your env.21
set -euo pipefail23
HERE="$(cd "$(dirname "$0")" && pwd)"24
SLATE_REPO="${1:-$HERE/../slate}"25
shift || true # remaining args pass through to `lantern run`26
LANTERN_BIN="$HERE/build/native/bin/lantern"28
[ -x "$LANTERN_BIN" ] || { echo "missing $LANTERN_BIN — run: sigil build lantern-cli --config native" >&2; exit 1; }30
# Accept a URL (http/https/file — served elsewhere, e.g. `sigil serve`), a repo31
# folder (…/build/web/index.html), or a web build dir directly. A URL passes32
# straight through to `lantern run`, which loads it directly (no lantern:// scheme,33
# no local build needed) — handy for testing a live-hosted build with no caching.34
case "$SLATE_REPO" in35
http://*|https://*|file://*)36
SLATE_BUILD="$SLATE_REPO"37
;;38
*)39
if [ -f "$SLATE_REPO/build/web/index.html" ]; then SLATE_BUILD="$SLATE_REPO/build/web"40
elif [ -f "$SLATE_REPO/index.html" ]; then SLATE_BUILD="$SLATE_REPO"41
else42
echo "no Slate web build found under: $SLATE_REPO" >&243
echo " expected $SLATE_REPO/build/web/index.html (build Slate first: sigil build)" >&244
echo " (or pass an http://…/https://…/file://… URL to load a hosted build)" >&245
exit 146
fi47
# Normalize to an absolute path so the guix-shell child resolves it correctly.48
SLATE_BUILD="$(cd "$SLATE_BUILD" && pwd)"49
;;50
esac52
echo "==> Slate repo: $SLATE_REPO"53
echo "==> Slate build: $SLATE_BUILD"54
echo "==> lantern: $LANTERN_BIN"55
echo "==> transparency: ON (toggle Slate translucency from its command palette)"57
exec guix shell -m "$HERE/gl-manifest.scm" -- bash -c '58
export LD_LIBRARY_PATH="$GUIX_ENVIRONMENT/lib"59
export LANTERN_LIB_DIR="$GUIX_ENVIRONMENT/lib"60
bin="$1"; build="$2"; shift 261
exec "$bin" run "$build" --title Slate --transparent "$@"62
' _ "$LANTERN_BIN" "$SLATE_BUILD" "$@"