#!/bin/bash # Friction launcher (Desktop entry, xterm, supervisor all go through here). # * LIBGL_ALWAYS_SOFTWARE=1: Skia on llvmpipe is the only GL in the sandbox. # * A per-user PulseAudio with a null sink: Qt Multimedia's pulse plugin is # the only audio backend in the bundle, and Friction's audio handler throws # a modal "Critical Error … Unsupported sample format 0" on launch when no # server answers. Root is fine for a private, dummy server. # * qt.conf resolves plugins/libs relative to bin/, so exec the real binary. # * nice 15 (t10i lesson, re-learned on t16 fable a1 2026-09-04): a Friction # render pegs all 4 cores + RAM, computer-1's screenshot exec then exceeds # Daytona's exec deadline ("Runtime action 'screenshot' failed (143): # Terminated") and harbor ends the trial with no reward after 5 h of work. # Renders inherit the niceness, so the exec daemon always gets CPU. # Repeated Desktop/Menu launches activate the existing window. exec 9>/tmp/t23-friction-launch.lock flock 9 if pgrep -x friction >/dev/null; then wmctrl -xa friction.friction 2>/dev/null || wmctrl -a Friction 2>/dev/null || true exit 0 fi export LIBGL_ALWAYS_SOFTWARE=1 export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/tmp/runtime-$(id -u)}" mkdir -p "$XDG_RUNTIME_DIR" && chmod 700 "$XDG_RUNTIME_DIR" if command -v pulseaudio >/dev/null && ! pgrep -x pulseaudio >/dev/null; then pulseaudio --daemonize=yes --exit-idle-time=-1 --disallow-exit \ --load="module-null-sink sink_name=dummy" >/dev/null 2>&1 || true fi nice -n 15 /opt/friction/bin/friction "$@" & TASK_FRICTION_PID=$! # Retain the launch lock until the binary appears in the process table. for i in $(seq 1 50); do pgrep -x friction >/dev/null && break kill -0 "$TASK_FRICTION_PID" 2>/dev/null || break sleep 0.1 done flock -u 9 exec 9>&- wait "$TASK_FRICTION_PID"