Files
digital-garden-flo/guides/TYPST.md
T
2026-10-14 11:50:01 +01:00

1.3 KiB

So for like live updating or recompiling the pdf document with a justfile that looks like this in one terminal window

watch-typst doc lang="da":
	typst watch --input lang={{ lang }} {{ doc }}.typ ./output/{{ doc }}-{{ lang }}.pdf

watch-pdf doc lang="da":
	watch-pdf ./output/{{ doc }}-{{ lang }}.pdf

build doc:
	typst compile --input lang=en {{ doc }}.typ ./output/{{ doc }}-en.pdf
	typst compile --input lang=da {{ doc }}.typ ./output/{{ doc }}-da.pdf
	typst compile --input lang=fo {{ doc }}.typ ./output/{{ doc }}-fo.pdf

While the machine having the watch-pdf script available in PATH

#!/usr/bin/env bash
set -euo pipefail     

[[ -z "$1" ]] && { echo "ERROR: No PDF filename provided"; exit 1; }
PDF_PATH="$1"

if [[ ! -f "${PDF_PATH}" ]]; then
  echo "ERROR: ${PDF_PATH} is not a regular file"
  exit 1
fi

command -v evince &> /dev/null || { echo "❌ evince not found. Install: sudo apt-get install evince"; exit 1; }

echo "=== Reload Watcher Started ==="
echo "Monitoring ${PDF_PATH} for writes…"

while IFS= read -r change_file; do
  [[ "${change_file}" == "${PDF_PATH}" ]] || continue
  echo "[$(date '+%Y-%m-%d %H:%M:%S')] ${PDF_PATH} modified → opening evince"
  evince "${PDF_PATH}" &
done < <(inotifywait -mr --format '%w%f' -e close_write "${PDF_PATH}")

echo "Watcher stopped."