#!/usr/bin/env bash # Re-record the manual: docs/manual/README.md's pictures, from the app itself. # # tools/manual/record.sh [scene...] # # Needs Xvfb, xdotool, ImageMagick's `import` and ffmpeg. Builds the desktop # binary if it is not there, starts a private X server, opens the folder as # a library in a throwaway profile, runs the scenes (all of them by default) # and writes PNGs and GIFs into docs/manual/media/. # # The library folder is the author's demo set — seventy face-free frames, # the twelve-frame panorama from fixtures/pano among them — and scenes.py's # cell coordinates assume its grid. Another folder needs those looked at. set -euo pipefail here="$(cd "$(dirname "$0")" && pwd)" repo="$(cd "$here/../.." && pwd)" library="${1:?library folder}" shift || true export DR_HOME="${DR_HOME:-/var/tmp/dr-manual}" export DR_DISPLAY="${DR_DISPLAY:-:7}" export DR_BIN="${DR_BIN:-$repo/target/release/darkroom-desktop}" media="$repo/docs/manual/media" mkdir -p "$media" "$DR_HOME/xdg/config/darkroom" "$DR_HOME/xdg/data/darkroom" [ -x "$DR_BIN" ] || (cd "$repo" && cargo build --release -p darkroom-desktop) # The models and the runtime are shared with the real profile: a segmenter # that is not there makes "Find subjects" a picture of nothing. for d in models runtime; do src="${XDG_DATA_HOME:-$HOME/.local/share}/darkroom/$d" [ -e "$src" ] && ln -sfn "$src" "$DR_HOME/xdg/data/darkroom/$d" done # A folder library, chosen: no launch screen on the way in. cat > "$DR_HOME/xdg/config/darkroom/sessions.json" </dev/null 2>&1; then Xvfb "$DR_DISPLAY" -screen 0 1920x1200x24 +extension GLX +render -noreset \ > "$DR_HOME/xvfb.log" 2>&1 & echo $! > "$DR_HOME/xvfb.pid" sleep 2 fi python3 "$here/drive.py" launch sleep 12 python3 "$here/scenes.py" "$media" "${@:-all}" python3 "$here/drive.py" stop # GIFs for the page; the MP4s are working files and are not kept. for mp4 in "$media"/*.mp4; do [ -e "$mp4" ] || continue "$here/gif.sh" "$mp4" "${mp4%.mp4}.gif" 960 10 rm "$mp4" done optipng -quiet -o2 "$media"/*.png || true