#!/usr/bin/env bash # Start a nested niri instance for the tests of dynamonix. # # The tests change the outputs. Do not use the socket of the compositor that # you work in. This script starts a different instance. set -euo pipefail directory="$(mktemp -d)" config="${directory}/config.kdl" cat > "${config}" <<'KDL' hotkey-overlay { skip-at-startup } layout { gaps 16 } KDL if [ -z "${WAYLAND_DISPLAY:-}" ]; then echo "error: WAYLAND_DISPLAY is not set. Start this script in a Wayland session." >&2 exit 1 fi before="$(ls "${XDG_RUNTIME_DIR}"/niri.*.sock 2>/dev/null || true)" niri -c "${config}" & compositor=$! for _ in $(seq 1 50); do sleep 0.1 after="$(ls "${XDG_RUNTIME_DIR}"/niri.*.sock 2>/dev/null || true)" socket="$(comm -13 <(echo "${before}") <(echo "${after}") | head -1)" if [ -n "${socket}" ]; then break fi done if [ -z "${socket:-}" ]; then echo "error: the nested instance did not make a socket." >&2 kill "${compositor}" 2>/dev/null || true exit 1 fi cat <