Skip to content
markksantosPublic

Repository files navigation

🔥 Afterburn

Detect heavy computational load and automatically optimize your Mac by pausing non-essential background processes.

Swift SwiftUI macOS License

Features · Getting Started · Tech Stack


Features

  • Real-Time System Monitoring — Live CPU, memory, and GPU metrics via Mach kernel APIs and IOKit, polled every 3 seconds
  • Automatic Afterburn Mode — State machine detects sustained heavy load and pauses background processes, Time Machine, and Spotlight indexing
  • Smart Cooldown — 30-second activation delay prevents false triggers; 60-second cooldown avoids flapping
  • Process Safety — Hardcoded blocklist protects critical system processes; PID recycling verification on crash recovery
  • Crash Recovery — Paused processes are tracked on disk and automatically resumed on relaunch if the app is force-killed
  • Signal Handling — SIGTERM and SIGINT handlers ensure all paused processes resume on graceful exit
  • Manual Afterburn — Force-activate with a custom duration via the menu bar popover
  • Optimization Profiles — Create and switch between profiles (Default, Light, Aggressive) with different thresholds and behaviors
  • Whitelist / Blacklist — Mark apps as never-pause or always-pause from a list of running applications
  • Activity History — SQLite-backed session log with peak CPU/memory, duration, and per-app pause records
  • Menu Bar Native — Flame icon with color-coded status (gray/green/yellow/red), no Dock icon

Getting Started

Prerequisites

  • macOS 13 Ventura or later
  • Swift 5.9+ (included with Xcode 15+)

Build & Run

Afterburn is a menu-bar (LSUIElement) SwiftUI app. It must run from a real .app bundle — the bare SwiftPM executable (swift run AfterburnApp) does not launch reliably because notifications and the accessory activation policy need a bundle identifier and an Info.plist. Use the bundled build script:

git clone https://github.com/markksantos/Afterburn.git
cd Afterburn
./build-app.sh           # produces build/Afterburn.app (ad-hoc signed)
open build/Afterburn.app # look for the flame icon in your menu bar

build-app.sh compiles a universal (arm64 + x86_64) release binary, assembles the bundle from Packaging/Info.plist, stamps the version, and ad-hoc signs it so it runs locally. See Packaging/README.md for the Developer-ID signing + notarization path used for distribution.

To run the test suite:

swift test

Permissions

  • Administrator privileges — Prompted via system dialog when pausing Time Machine (tmutil) or Spotlight (mdutil). You can deny without breaking core functionality.
  • Notifications — macOS will prompt to allow notifications for Afterburn session start/end alerts.

Tech Stack

Component Technology
Language Swift 5.9
UI Framework SwiftUI + MenuBarExtra
CPU Monitoring Mach host_processor_info (delta-based)
Memory Monitoring Mach host_statistics64
GPU Monitoring IOKit IOAccelerator
Process Control POSIX SIGSTOP / SIGCONT
Database SQLite via raw C API (system library)
Admin Privileges NSAppleScript with administrator privileges
Signal Safety DispatchSource.makeSignalSource
Package Manager Swift Package Manager

Project Structure

Afterburn/
├── Package.swift
├── build-app.sh            # assembles Afterburn.app from the SwiftPM build
├── Packaging/
│   ├── Info.plist          # bundle metadata (LSUIElement, version placeholders)
│   ├── Afterburn.entitlements
│   └── README.md           # signing / notarization / why no App Sandbox
├── Sources/
│   ├── CSQLite/
│   │   ├── module.modulemap
│   │   └── shim.h
│   ├── AfterburnEngine/
│   │   ├── ActivityLog.swift
│   │   ├── AfterburnController.swift
│   │   ├── CPUMonitor.swift
│   │   ├── DatabaseManager.swift
│   │   ├── GPUMonitor.swift
│   │   ├── LoadStatus.swift
│   │   ├── MemoryMonitor.swift
│   │   ├── PrivilegeHelper.swift
│   │   ├── ProcessManager.swift
│   │   ├── Profile.swift
│   │   ├── ProfileManager.swift
│   │   ├── SafetyManager.swift
│   │   ├── Settings.swift
│   │   └── SystemMonitor.swift
│   ├── AfterburnUI/
│   │   ├── Components/
│   │   │   ├── GaugeView.swift
│   │   │   └── StatusBadge.swift
│   │   ├── HistoryView.swift
│   │   ├── ManualAfterburnView.swift
│   │   ├── PopoverView.swift
│   │   ├── ProfilesView.swift
│   │   ├── SettingsView.swift
│   │   ├── StatusBarIcon.swift
│   │   ├── SystemMetricsView.swift
│   │   └── WhitelistBlacklistView.swift
│   └── AfterburnApp/
│       ├── AfterburnApp.swift
│       └── AppDelegate.swift
└── Tests/
    └── AfterburnEngineTests/
        ├── LoadStatusTests.swift
        ├── AfterburnConfigTests.swift
        ├── AfterburnStateTests.swift
        └── AfterburnControllerTests.swift

Distribution

Afterburn is direct-download only — it cannot ship on the Mac App Store because pausing arbitrary processes (SIGSTOP/SIGCONT), reading host-wide CPU/GPU stats, and escalating privileges to drive tmutil/mdutil are all forbidden inside the App Sandbox. Release builds are signed with a Developer ID certificate, notarized, and stapled. The exact commands are in Packaging/README.md.

License

MIT License © 2026 Mark Santos


Built with ❤️ by NoSleepLab

Releases

Packages

Contributors

Languages