AtlatestRepositorylantern

lantern / treerun-slate.sh

1#!/usr/bin/env bash
2# Launch Slate in a native Lantern window with TRANSPARENCY on + REAL local
3# 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.html
8# after `sigil build`), a web build dir directly, or an http/https/file URL of a
9# hosted build (e.g. `sigil serve` — loaded directly, no local build / no cache).
10# Defaults to the sibling `slate` checkout. It resolves the
11# 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 launches
13# with --transparent so the window is transparency-CAPABLE.
15# Transparency is opt-in-safe: with Slate's own translucency OFF (the default) the
16# window looks completely normal; toggle Slate translucency ON (command palette:
17# "Transparency: on") and the desktop shows through the frosted content.
19# If the window never maps, re-run with LANTERN_SOFTWARE_RENDER=1 (the Mesa GL
20# loader-path gotcha) — it is passed through to the child if set in your env.
21set -euo pipefail
23HERE="$(cd "$(dirname "$0")" && pwd)"
24SLATE_REPO="${1:-$HERE/../slate}"
25shift || true # remaining args pass through to `lantern run`
26LANTERN_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 repo
31# folder (…/build/web/index.html), or a web build dir directly. A URL passes
32# 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.
34case "$SLATE_REPO" in
35 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 else
42 echo "no Slate web build found under: $SLATE_REPO" >&2
43 echo " expected $SLATE_REPO/build/web/index.html (build Slate first: sigil build)" >&2
44 echo " (or pass an http://…/https://…/file://… URL to load a hosted build)" >&2
45 exit 1
46 fi
47 # Normalize to an absolute path so the guix-shell child resolves it correctly.
48 SLATE_BUILD="$(cd "$SLATE_BUILD" && pwd)"
49 ;;
50esac
52echo "==> Slate repo: $SLATE_REPO"
53echo "==> Slate build: $SLATE_BUILD"
54echo "==> lantern: $LANTERN_BIN"
55echo "==> transparency: ON (toggle Slate translucency from its command palette)"
57exec 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 2
61 exec "$bin" run "$build" --title Slate --transparent "$@"
62' _ "$LANTERN_BIN" "$SLATE_BUILD" "$@"