$ show aspauldingcode/apple-sharpener
Apple Sharpener is a macOS system tweak that programmatically removes or customizes window corner radii, producing sharp (square) corners on application windows and optionally modifying the Dock's corner radius. It operates as an injectable dynamic library (dylib) loaded via the Ammonia injection framework and provides a CLI tool (`sharpener`) for runtime control. The architecture is a classic method swizzling tweak: the dylib hooks into `NSWindow` methods (`setFrame:display:`, `_setCornerRadius:`, `_updateCornerMask`) and the Dock's `CALayer` (`layoutSublayers`) to enforce a configurable corner radius. State is persisted via `NSUserDefaults` (in a shared suite) and communicated between processes using `notifyd` distributed notifications, allowing live changes without restarting applications. The tweak intelligently filters windows to affect only standard titled windows (excluding HUD, utility, popups, and small UI elements) and handles fullscreen mode gracefully. This is a targeted utility built for a specific use case within the macOS jailbreak/tweak ecosystem, demonstrating solid Objective-C craftsmanship and careful integration with the Cocoa framework.
The LLM identified 3 files worth highlighting for reuse:
Implements the core window corner radius modification logic. Contains the highly optimized `isStandardAppWindow` inline function that correctly filters out HUD, utility, tooltip, and small windows, ensuring only standard titled windows are affected. Uses ZKSwizzle to hook `NSWindow` methods and applies custom radius via KVC on `cornerRadius`. Notification handlers on `NSWindowDidBecomeMain` and `NSWindowDidBecomeKey` catch window lifecycle events. The code demonstrates careful recursion avoidance and fullscreen safety. This module is a reusable pattern for any macOS tweak that needs to selectively modify window properties.
Hooks the Dock's CALayer `layoutSublayers` method using direct IMP replacement (not ZKSwizzle) to intercept layout and apply custom corner radius to `DockCore.ModernFloorLayer` and other dock-related layers. Also hooks `WALayerKitWindow -layer` to capture the root layer. Includes a broad detection heuristic for dock layers by class name substring matching. This pattern of hooking `layoutSublayers` on CALayer is a non-obvious technique for customizing system UI elements that lack public API, and the detection logic is adaptable to other layer-based customization scenarios.
A standalone CLI tool that communicates with the injected dylib via macOS notifyd distributed notifications and NSUserDefaults. Parses commands (`on`, `off`, `toggle`, `--radius`, `--dock-radius`, `--status`, `--version`) using pure string comparison without external libraries. Demonstrates the correct use of `notify_register_check` for one-shot status reading and `notify_post` for event signaling. The tool also writes persistent state to a shared NSUserDefaults suite, enabling state hydration across process restarts. This architecture is a clean example of cross-process IPC for a system tweak that could be reused in similar projects needing a separate control tool.