Advanced Workflows
Biometric User Switching & Unix Process Freezing
Beyond Spaces: Complete Workflow Isolation on macOS with Touch ID and SIGSTOP
This is for macOS power users with diverse workflows. If you have one machine and write code, edit video, and run agents this is a way to separate workflows into different local users and experimentally pause GUI apps belonging to inactive accounts.
Core technique
The problem
Virtual Desktops (Spaces) and Stage Manager provide visual compartmentalization, but fail at process isolation. Heavy background apps—DAWs like Logic Pro, browser render helpers, Docker and local servers—keep demanding render updates from WindowServer and competing for CPU.
The dual-layer solution
2. Kernel layer — Experimental SIGSTOP / SIGCONT of discovered .app processes for inactive users. This suspends those targets; it does not snapshot the environment, free RAM, or guarantee zero GPU/audio/system work.
Experimental. Fingerprint-to-account switching observations and any WindowServer numbers below are a Trackpad Ninja experiment, not Apple-documented guarantees.
SIGSTOPstops scheduling for the processes you successfully signal; it does not free RAM, stop every related service, or freeze shell-launched servers outside.app/ Applications paths.
Why Would You Want To Do This?
Spaces organize your screen, but they do not isolate system resources. Background renderers, audio engines, and local servers can keep running while you work elsewhere. Putting each heavy workflow in its own local user account creates stronger separation. Pausing selected inactive-account GUI processes with SIGSTOP can reduce their CPU scheduling while keeping them resident in RAM—useful on a high-RAM Mac, with clear limits.
If you have a powerful M-series computer with plenty of RAM, this can stretch one machine across studio and agent workloads before buying dedicated hardware.
On my machine, I have a primary account, a music account, and an agent account. The script below is a dry-run-friendly helper for listing and signaling discovered app processes—not a complete isolation product.
Layer 1: The Biometric Gateway
macOS can enroll distinct fingers against different local user accounts when Fast User Switching is enabled. Rest or press an assigned finger on Touch ID and macOS may switch users.
Apple prerequisites (required):
- Fast User Switching enabled (Control Center / Users & Groups, depending on macOS version).
- The target user must already have logged in with a password at least once in the session history macOS expects.
- macOS can still require a password again (policy, sleep, FileVault, or timed lock). Treat “no password prompt” as a hoped-for outcome on a tested configuration—not an unconditional feature.
Observation (tested on one configuration, not a general guarantee): using the same enrolled finger can appear to toggle between users. Keep that as a labeled observation until you reproduce it on your Mac.
Getting the feel for user switching takes practice.
- Enroll one finger on your primary (dev) account.
- Enroll a different finger on your audio / media account.
- Leave each account’s login items and Dock dedicated to that domain.
| Finger / biometric input | Local account name | Dedicated task domain | Startup application footprint |
|---|---|---|---|
| Index finger | dev (example) |
Code, browsers, Docker / local servers | Xcode or editor, Terminal, browsers, containers |
| Middle finger | audio (example) |
Audio / media production | Logic Pro, sample libraries, audio utilities |
Layer 2: Display Lag and the Spinning Beach Ball
macOS relies on WindowServer to composite interface elements. When background sessions stay fully active, hidden windows can still request updates.
Freezing some inactive-session GUI processes can reduce those draw requests. It does not prove absolute-zero GPU or CoreAudio load, and it does not cover every helper or daemon.
Bounded expectations
What SIGSTOP can do (for successfully signaled PIDs):
- Stop further CPU scheduling of those processes until
SIGCONT. - Leave their memory resident (no RAM reclaim from the signal itself).
What it does not do:
- Snapshot or restore an environment.
- Discover shell-launched servers, nested helpers outside the path filters, or shared system services.
- Guarantee zero WindowServer / GPU / audio work from other processes.
Layer 3: The Automation Engine (focus-user.py)
Deploy the script to /Users/Shared/focus-user.py so every local account can run it. Prefer an isolated disposable Mac user before any production use.
cd /Users/Shared
vi focus-user.pyPaste the production script into that file (or use Download focus-user.py on the block below, then move the file into /Users/Shared/):
#!/usr/bin/env python3
"""Experimental per-user GUI process freeze/wake helper.
Discovers processes whose command paths contain ".app/" or "/Applications/".
Does not manage shell-launched servers, arbitrary daemons, or shared services.
Default mode is dry-run. Requires appropriate privilege to signal other users.
"""
from __future__ import annotations
import argparse
import os
import re
import subprocess
import sys
from pathlib import Path
APP_BUNDLE_RE = re.compile(r"(/.*\.app)(?:/|$)", re.IGNORECASE)
def get_system_users():
"""Interactive human accounts (UID >= 500), excluding Guest."""
try:
out = subprocess.check_output(
["dscl", ".", "-list", "/Users", "UniqueID"], text=True
)
users = []
for line in out.splitlines():
parts = line.strip().split()
if len(parts) != 2:
continue
username, uid_str = parts
try:
uid = int(uid_str)
except ValueError:
continue
if uid >= 500 and not username.startswith("_") and username != "Guest":
users.append(username)
return sorted(users)
except Exception:
try:
return [
d
for d in os.listdir("/Users")
if not d.startswith(".") and d not in ("Shared", "Guest")
]
except Exception:
return []
ALL_USERS = get_system_users()
CURRENT_USER = os.environ.get("SUDO_USER") or os.getlogin()
# Compare lowercased *bundle names* extracted from full .app paths (spaces kept).
CRITICAL_EXCLUDES = {
"terminal.app",
"iterm.app",
"iterm2.app",
"finder.app",
"dock.app",
"system settings.app",
"activity monitor.app",
"loginwindow",
"distnoted",
"cfprefsd",
"tccd",
"launchd",
"usereventagent",
"ssh",
"sshd",
"bash",
"zsh",
"sh",
"python3",
}
def run_cmd(cmd):
try:
res = subprocess.run(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
)
if res.stderr.strip():
print(f"[stderr] {' '.join(cmd)}: {res.stderr.strip()}", file=sys.stderr)
return res.stdout.strip()
except Exception as exc:
print(f"[error] {' '.join(cmd)}: {exc}", file=sys.stderr)
return ""
def bundle_identity(cmd: str) -> str:
"""Return the .app bundle filename (spaces preserved), else basename."""
match = APP_BUNDLE_RE.search(cmd)
if match:
return Path(match.group(1)).name
return os.path.basename(cmd.split()[0])
def get_user_apps(username):
out = run_cmd(["ps", "-u", username, "-o", "pid=,state=,command="])
if not out:
return []
apps = []
for line in out.splitlines():
parts = line.strip().split(None, 2)
if len(parts) < 3:
continue
pid, state, cmd = parts[0], parts[1], parts[2]
if ".app/" not in cmd and "/Applications/" not in cmd:
continue
app_name = bundle_identity(cmd)
if app_name.lower() in CRITICAL_EXCLUDES:
continue
is_frozen = "T" in state
apps.append(
{
"pid": pid,
"name": app_name,
"state": "FROZEN" if is_frozen else "RUNNING",
"is_frozen": is_frozen,
}
)
seen = set()
unique = []
for a in apps:
if a["pid"] in seen:
continue
seen.add(a["pid"])
unique.append(a)
return sorted(unique, key=lambda x: x["name"])
def signal_pids(pids, sig_flag, *, dry_run: bool):
success = 0
failures = []
for pid in pids:
if dry_run:
print(f" dry-run: would kill {sig_flag} {pid}")
success += 1
continue
res = subprocess.run(
["sudo", "kill", sig_flag, str(pid)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)
if res.returncode == 0:
success += 1
else:
err = (res.stderr or res.stdout or "unknown failure").strip()
failures.append((pid, err))
print(f" failed {sig_flag} pid={pid}: {err}", file=sys.stderr)
return success, failures
def parse_args(argv=None):
p = argparse.ArgumentParser(description="List/stop/resume discovered GUI apps per user.")
p.add_argument(
"--action",
choices=("list", "stop", "resume", "prompt"),
default="list",
help="list (default dry inventory), stop, resume, or interactive prompt",
)
p.add_argument("--user", action="append", dest="users", help="Limit to user(s)")
p.add_argument(
"--include-active",
action="store_true",
help="Allow signaling the active session (default: skip CURRENT_USER)",
)
p.add_argument(
"--apply",
action="store_true",
help="Actually send signals (default is dry-run)",
)
return p.parse_args(argv)
def main(argv=None):
args = parse_args(argv)
dry_run = not args.apply
targets = args.users or ALL_USERS
print("=" * 60)
print(f" WORKFLOW PROCESS REPORT ({CURRENT_USER}) dry_run={dry_run}")
print("=" * 60)
user_data = {}
for user in targets:
if user not in ALL_USERS:
print(f"\nUSER: {user} (unknown — skipped)")
continue
tag = " (ACTIVE SESSION)" if user == CURRENT_USER else ""
print(f"\nUSER: {user}{tag}")
apps = get_user_apps(user)
user_data[user] = apps
if not apps:
print(" (No matching .app / Applications processes)")
continue
shown = set()
for app in apps:
if app["name"] in shown:
continue
shown.add(app["name"])
print(f" - [{app['state']:<7}] {app['name']} pid={app['pid']}")
if args.action == "list":
print("\nDone (list only). Pass --action stop|resume --apply to signal.")
return
print("\n" + "=" * 60)
print(" PROCESS MANAGEMENT")
print("=" * 60)
for user in targets:
apps = user_data.get(user, [])
if not apps:
continue
if user == CURRENT_USER and not args.include_active:
print(f"\nSkipping active session {user} (pass --include-active to override).")
continue
frozen = [a for a in apps if a["is_frozen"]]
running = [a for a in apps if not a["is_frozen"]]
if args.action == "stop":
action_verb, sig_flag, chosen = "Freeze", "-STOP", running
elif args.action == "resume":
action_verb, sig_flag, chosen = "Wake", "-CONT", frozen
else:
# Explicit prompt: offer both when mixed; never infer from a 50% heuristic alone.
print(f"\n{user}: {len(running)} running, {len(frozen)} frozen")
try:
choice = input("Type stop, resume, or skip: ").strip().lower()
except (EOFError, KeyboardInterrupt):
print("\nAborted.")
sys.exit(0)
if choice in ("stop", "freeze"):
action_verb, sig_flag, chosen = "Freeze", "-STOP", running
elif choice in ("resume", "wake"):
action_verb, sig_flag, chosen = "Wake", "-CONT", frozen
else:
print(f"--> Skipped {user}.")
continue
if not chosen:
print(f"--> Nothing to {action_verb.lower()} for {user}.")
continue
if args.action == "prompt":
try:
confirm = input(f"{action_verb} {len(chosen)} pid(s) for {user}? [y/N]: ").strip().lower()
except (EOFError, KeyboardInterrupt):
print("\nAborted.")
sys.exit(0)
if confirm not in ("y", "yes"):
print(f"--> Skipped {user}.")
continue
count, _failures = signal_pids(
[a["pid"] for a in chosen], sig_flag, dry_run=dry_run
)
print(f"--> {action_verb}: {count} process(es) for {user} ({sig_flag}).")
print("\nDone.")
if __name__ == "__main__":
main()What the script does on each run:
- Discovers interactive users with
dscl(UID ≥ 500; skips daemons and Guest). - Targets process command lines containing
.app/or/Applications/only. - Parses bundle identity from the full
.apppath so names with spaces (e.g.System Settings.app) match the whitelist. - Never freezes the lifeline whitelist:
Terminal.app,iTerm/iTerm2,Finder,Dock,System Settings.app,Activity Monitor.app, shells,python3, and SSH. - Defaults to list + dry-run; use
--action stop|resume --apply(or--action prompt) explicitly. - Skips the active session unless
--include-activeis set. - Surfaces
killfailures on stderr instead of discarding them.
Keep Terminal (or iTerm) and SSH on the whitelist. Without that lifeline, a frozen session can strand you with no local UI escape.
Layer 4: The Fail-Safe / Rescue Lifeline
Never leave a workspace without an escape hatch.
Create /Users/Shared/rescue.py the same way (or Download rescue.py from the block below):
cd /Users/Shared
vi rescue.py
chmod 755 rescue.py#!/usr/bin/env python3
"""Resume stopped processes for a user. Cross-user rescue needs sudo."""
import os
import subprocess
import sys
user = os.environ.get("SUDO_USER") or os.getlogin()
if len(sys.argv) > 1:
user = sys.argv[1]
cmd = ["sudo", "pkill", "-CONT", "-u", user]
print("Running:", " ".join(cmd))
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError as exc:
print(f"Rescue failed for {user}: {exc}", file=sys.stderr)
sys.exit(exc.returncode)
print(f"Sent SIGCONT to processes for {user} (privilege permitting).")Set permissions, then prefer dry-run inventory before apply:
chmod 755 focus-user.py
python3 /Users/Shared/focus-user.py --action list
sudo python3 /Users/Shared/focus-user.py --action resume --applyHard reboot stays last resort.
The Muscle Memory Ritual
- Depart — Stop audio transport or long builds. Tap Touch ID with the enrolled finger for the destination account (password may still be required).
- Arrive — Open Terminal. Run
python3 /Users/Shared/focus-user.py --action list, then resume/stop with--applyonly after the inventory looks right. - Execute — Reduced competition from the processes you froze—not a promise of absolute-zero system load.
Acceptance bounds (read before treating this as production-ready)
- Measure before/after on your hardware and workload; do not cite absolute-zero CPU/GPU/CoreAudio as a product claim.
- Fixtures for
System Settings.app,Activity Monitor.app, nested helpers, and paths with spaces must keep the correct bundle identity. - Mixed frozen/running states always expose an explicit resume path (
--action resume), not a majority-state heuristic. - Verify in an isolated disposable account before using on important sessions.