#!/bin/sh # Runs in the guest, as the logged-in user, to make it what a scenario clones: the agent starts at # login from a Terminal window (which holds the grants, so the agent and the daemon it starts are # attributed to it), nothing from earlier runs is left, and Terminal does not reopen old windows. set -eu pkill -x komorebi || true pkill -f komorebi-e2e-agent || true pkill -f komorebi-testwin || true killall Terminal 2>/dev/null || true sleep 1 rm -rf "$HOME/Library/Saved Application State/com.apple.Terminal.savedState" \ "$HOME/Library/Application Support/komorebi" defaults write com.apple.Terminal NSQuitAlwaysKeepsWindows -bool false defaults write -g ApplePersistenceIgnoreState -bool true mkdir -p "$HOME/e2e/bin" "$HOME/e2e/tmp" "$HOME/Library/LaunchAgents" # what the launch agent opens: a Terminal window that runs the agent cat > "$HOME/e2e/agent.command" < "$HOME/Library/LaunchAgents/dev.komorebi.e2e-agent.plist" < Labeldev.komorebi.e2e-agent ProgramArguments /usr/bin/open-aTerminal $HOME/e2e/agent.command RunAtLoad LimitLoadToSessionTypeAqua PLIST plutil -lint "$HOME/Library/LaunchAgents/dev.komorebi.e2e-agent.plist"