Files
Omarchy-Stream/lib/config.sh
Levi Woodard 171ade4ff1 Add headless streaming mode + Mac client + full docs
Headless mode (new) — for KVM-attached hosts streaming to disconnected clients
- --headless / --mirror flags; default headless on hostname JARVIS, mirror elsewhere
- New lib/headless.sh installs prep-cmd hooks to ~/.local/share/omarchy-moonlight/bin
- bin/sunshine-stream-do.sh creates/resizes a Hyprland HEADLESS-1 output to the
  connecting client's resolution and migrates the active workspace onto it
- bin/sunshine-stream-undo.sh tears down the headless output on disconnect and
  returns the workspace to a non-headless monitor when one is available
- lib/config.sh writes capture=wlr, output_name=HEADLESS-1, and the JSON
  global_prep_cmd entry referencing the installed hook paths
- lib/preflight.sh adds a preflight_headless step that checks hyprctl, jq, and
  a running Hyprland session (warn-only, install can proceed)
- lib/verify.sh adds checks for the hook scripts and the wlr/global_prep_cmd
  config lines

Mac client
- client/install-macos.sh: Darwin guard, Homebrew presence check, brew cask
  install of Moonlight, idempotent
- client/README.md: per-platform install (macOS / Android / iOS / Apple TV /
  Linux + Steam Deck) and the five-step first-pair walkthrough

Other
- jq added to the helper install set in lib/packages.sh (hooks parse Hyprland
  JSON output)
- README.md rewritten to cover both modes, the new flags, the tuned defaults
  per mode + per vendor, the headless internals, and the client pointer
2026-05-18 10:31:08 -06:00

80 lines
2.5 KiB
Bash

#!/usr/bin/env bash
# Write a tuned ~/.config/sunshine/sunshine.conf for low-latency LAN streaming.
# Only overwrites if (a) no config exists, or (b) our managed marker is present.
SUNSHINE_CONF_DIR="$HOME/.config/sunshine"
SUNSHINE_CONF="$SUNSHINE_CONF_DIR/sunshine.conf"
MANAGED_MARKER="# managed-by: omarchy-moonlight"
write_sunshine_config() {
local mode="${1:-mirror}"
mkdir -p "$SUNSHINE_CONF_DIR"
if [[ -f "$SUNSHINE_CONF" ]] && ! grep -qF "$MANAGED_MARKER" "$SUNSHINE_CONF"; then
ok "Existing sunshine.conf is user-managed — leaving it alone"
info " To re-apply tuned defaults, delete $SUNSHINE_CONF and re-run install.sh"
return 0
fi
local encoder_block
case "$GPU_VENDOR" in
nvidia)
encoder_block=$'encoder = nvenc\nnvenc_preset = p1\nnvenc_tune = ll\nnvenc_rc = cbr\nnvenc_coder = auto'
;;
amd)
encoder_block=$'encoder = vaapi\namd_quality = speed\namd_rc = cbr\namd_usage = ultralowlatency'
;;
intel)
encoder_block=$'encoder = quicksync\nqsv_preset = veryfast\nqsv_coder = auto'
;;
*)
encoder_block=$'# encoder auto-detected by Sunshine'
;;
esac
local capture_block
case "$mode" in
headless)
# wlr capture of the Hyprland headless output that prep-cmd hooks create.
# global_prep_cmd is parsed as a JSON array by Sunshine, so keep it on one line.
capture_block="# Capture: wlr — captures a Hyprland headless output created on stream start.
capture = wlr
output_name = HEADLESS-1
# Hooks that create/resize HEADLESS-1 on stream start and remove it on stop.
global_prep_cmd = [{\"do\":\"${DO_SCRIPT}\",\"undo\":\"${UNDO_SCRIPT}\"}]"
;;
mirror|*)
capture_block="# Capture: KMS (DRM) — the right choice on Wayland.
capture = kms"
;;
esac
info "Writing tuned $SUNSHINE_CONF (GPU: $GPU_VENDOR, mode: $mode)"
cat >"$SUNSHINE_CONF" <<EOF
$MANAGED_MARKER
# Generated by omarchy-moonlight install.sh on $(date -Iseconds)
# Delete this marker line to take ownership; the installer will then leave the file alone.
#
# Tuned for low-latency LAN streaming on Hyprland/Wayland.
# Tune further via the web UI at https://localhost:47990
sunshine_name = ${HOSTNAME_SHORT}
$capture_block
# Encoder tuned for $GPU_VENDOR
$encoder_block
# Threading — more threads helps high-bitrate H.265/AV1.
min_threads = 4
# Use the PipeWire pulse compatibility layer for audio.
audio_sink = pulse
# Keyboard / mouse / gamepad pass-through via /dev/uinput.
# (Requires user to be in the 'input' group; install.sh handles this.)
EOF
ok "Wrote sunshine.conf"
}