No description
- Swift 97.2%
- Makefile 2.8%
| Sources/FocusBlur | ||
| .DS_Store | ||
| .gitignore | ||
| Makefile | ||
| Package.swift | ||
| README.md | ||
FocusBlur
A native macOS menu-bar app that blurs all background windows, keeping only the focused window sharp — similar to Monocle.
Requirements: macOS 26 (Tahoe) or later, Swift 6+
Building manually
1. Clone the repository
git clone <repo-url>
cd <repo>
2. Build a release binary
swift build -c release
The compiled binary lands at:
.build/release/FocusBlur
3. Create the .app bundle
mkdir -p FocusBlur.app/Contents/MacOS
mkdir -p FocusBlur.app/Contents/Resources
cp .build/release/FocusBlur FocusBlur.app/Contents/MacOS/
chmod +x FocusBlur.app/Contents/MacOS/FocusBlur
4. Write Info.plist
cat > FocusBlur.app/Contents/Info.plist << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key><string>FocusBlur</string>
<key>CFBundleIdentifier</key><string>com.local.FocusBlur</string>
<key>CFBundleName</key><string>FocusBlur</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleShortVersionString</key><string>1.0</string>
<key>NSPrincipalClass</key><string>NSApplication</string>
<key>NSHighResolutionCapable</key><true/>
<key>LSUIElement</key><true/>
<key>NSAccessibilityUsageDescription</key>
<string>FocusBlur needs Accessibility access to detect which window is focused.</string>
</dict>
</plist>
EOF
5. Ad-hoc codesign
codesign --sign - --force --deep FocusBlur.app
6. Install and run
cp -r FocusBlur.app /Applications/
open /Applications/FocusBlur.app
Updating an existing install (rebuild + redeploy in one step)
swift build -c release && \
pkill -x FocusBlur; sleep 0.3; \
cp .build/release/FocusBlur /Applications/FocusBlur.app/Contents/MacOS/FocusBlur && \
codesign --sign - --force --deep /Applications/FocusBlur.app && \
open /Applications/FocusBlur.app
First launch
macOS will prompt for Accessibility permission — this is required to detect which window is focused. Go to:
System Settings → Privacy & Security → Accessibility → enable FocusBlur
The blur activates automatically within one second of granting permission. No Screen Recording permission is needed.
How it works
- Window detection —
AXUIElementAccessibility API tracks the frontmost window viaAXObservernotifications (event-driven, ~0.1% CPU idle) - Blur overlay — stacked
NSVisualEffectViewlayers with simultaneous alpha control; multiple passes compound to produce a heavy opaque blur without private APIs or Screen Recording - Overlay positioning — the overlay window sits at
.normallevel and is placed just below the focused window viaorder(.below, relativeTo: windowID); the focused window occludes the blur naturally - Auto-focus fallback — when the frontmost app has no visible windows (all minimized),
CGWindowListCopyWindowInfofinds the topmost visible window of the next app on screen and anchors to that instead - Mouse wiggle — rapid back-and-forth shake (3+ direction reversals in 600 ms) toggles the blur on/off
Project structure
.
├── Package.swift
├── README.md
├── .gitignore
└── Sources/FocusBlur/
├── FocusBlurApp.swift # @main, AppDelegate, menu bar setup
├── Models/
│ └── AppSettings.swift # Persisted user settings
├── Services/
│ ├── BlurOverlayWindow.swift # NSWindow subclass — stacked blur layers
│ ├── WindowManager.swift # AX tracking, overlay lifecycle
│ └── MouseShakeDetector.swift
└── Views/
└── ContentView.swift # Liquid glass settings panel