Something went wrong. Try again.
Global — KDE Connect–compatible mobile companion (Gleam + egui/vidya dist-ui)
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495#!/usr/bin/env bash# Launch Global (Gleam + Plushie). Scrubs non-latin-1 env and sets graphics libs.set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"cd "$ROOT"
# --- Erlang on PATH (Gleam dies with "Program not found: erl" without it) ---if ! command -v erl >/dev/null 2>&1; then if command -v nix >/dev/null 2>&1; then ERL_OUT="$( nix --extra-experimental-features 'nix-command flakes' build --no-link \ --print-out-paths --builders '' \ nixpkgs#beamPackages.erlang 2>/dev/null | head -1 )" || true if [[ -n "${ERL_OUT:-}" && -x "$ERL_OUT/bin/erl" ]]; then export PATH="$ERL_OUT/bin:$PATH" fi fi # Common Nix store fallbacks already present on this machine if ! command -v erl >/dev/null 2>&1; then for d in /nix/store/*-erlang-*/bin; do if [[ -x "$d/erl" ]]; then export PATH="$d:$PATH" break fi done fifiif ! command -v erl >/dev/null 2>&1; then echo "error: erl not found. Gleam needs Erlang to run (target=erlang)." >&2 echo " nix shell nixpkgs#beamPackages.erlang nixpkgs#gleam -c gleam run" >&2 echo " # or: nix develop (from this flake)" >&2 exit 1fi
# --- renderer ---if [[ -z "${PLUSHIE_BINARY_PATH:-}" ]]; then if [[ -x "$ROOT/bin/plushie-renderer" ]]; then export PLUSHIE_BINARY_PATH="$ROOT/bin/plushie-renderer" elif [[ -x "$ROOT/result/lib/global/bin/plushie-renderer" ]]; then export PLUSHIE_BINARY_PATH="$ROOT/result/lib/global/bin/plushie-renderer" fifi
# --- packaged shortcut ---if [[ "${1:-}" == "--packaged" ]]; then shift if [[ ! -x "$ROOT/result/bin/global" ]]; then echo "No ./result/bin/global — run: nix build .#global --builders ''" >&2 exit 1 fi exec "$ROOT/result/bin/global" "$@"fi
if [[ -z "${PLUSHIE_BINARY_PATH:-}" || ! -x "$PLUSHIE_BINARY_PATH" ]]; then echo "Fetching plushie-renderer..." "$ROOT/scripts/fetch-renderer" export PLUSHIE_BINARY_PATH="$ROOT/bin/plushie-renderer"fi
# --- graphics libs (NixOS) ---if command -v nix >/dev/null 2>&1; then GFX="$( nix --extra-experimental-features 'nix-command flakes' eval --raw --impure --expr ' let pkgs = import <nixpkgs> {}; lib = pkgs.lib; in lib.makeLibraryPath (with pkgs; [ wayland libxkbcommon libGL vulkan-loader libx11 libxcursor libxi libxrandr libffi ]) ' 2>/dev/null || true )" if [[ -n "${GFX:-}" ]]; then export LD_LIBRARY_PATH="${GFX}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" fifi
# --- drop non-latin-1 env (nu prompts crash Plushie env FFI) ---while IFS= read -r k; do unset -v "$k" 2>/dev/null || truedone < <(python3 -c 'import osfor k, v in list(os.environ.items()): try: k.encode("latin-1"); v.encode("latin-1") except UnicodeEncodeError: if k.replace("_","").isalnum(): print(k)')
exec gleam run "$@"