I wish this was available for Sway. Could be great for old laptops.
Care will also have to be taken to handle the case when focus moves to a container rather than a window.
I use a similar SIGSTOP/SIGCONT script myself, but it's for when I turn my desktop PC's monitors off for the night rather than focus changes. It uses `swaymsg -t subscribe -m '["workspace"]'` for `"move"` events; when windows move to the "NOOP-1" workspace their processes get SIGSTOP'd, and when they move from the "NOOP-1" workspace their processes get SIGCONT'd.