#!/usr/bin/env bash APP_NAME="firefox-esr" APP_COMMAND="firefox-esr" while true; do if ! pgrep -x "$APP_NAME" > /dev/null; then swaymsg exec "$APP_COMMAND" fi sleep 1 # Wait a second before checking again done