The title could clarify it's for MacOS X.
Linux users probably already have some weird workflow with X11 virtual buffers to do this.
#!/bin/bash
swaymsg create_output OUTPUT=$(swaymsg -r -t get_outputs | jq '.[].name' | grep HEADLESS | tr -d '"')
# No need to reduce res, it defualts to 1080p #swaymsg output "$OUTPUT" resolution 1280x720
wl-mirror "$OUTPUT"
swaymsg output "$OUTPUT" unplug
When I was still in X11 land I used to just use Xephyr.