r/macosprogramming • • 11h ago

Building a live Earth wallpaper: desktop-level NSWindows, a WKWebView renderer and a frame rate that follows the motion

Post image
6 Upvotes

I've been working on a hobby project, a macOS app that puts a live 3D Earth behind the desktop icons (real sun position, city lights at night, satellite clouds). It's open source and I thought some of the implementation details might be interesting here. I'd also really like feedback on a few decisions.

How it's put together:

- One borderless NSWindow per screen at CGWindowLevelForKey(.desktopWindow), with collectionBehavior [.canJoinAllSpaces, .stationary, .ignoresCycle, .fullScreenNone] and ignoresMouseEvents = true. That keeps it under the icons on every Space and lets clicks through to Finder.

- The Earth itself is a three.js (r160) page in a WKWebView. It's loaded through a custom WKURLSchemeHandler (earth://app/...) because ES modules don't load from file:// URLs.

- The subsolar point uses the low-precision formulas from the Astronomical Almanac, which are good to about 0.01°. That's plenty for a wallpaper.

- Frame rate: the renderer works out how many pixels per second the image actually moves (from zoom, pitch and the motion mode) and schedules frames accordingly, down to one frame every 5 seconds. Camera moves still get the full 30 fps. It pauses on NSWindow.didChangeOcclusionStateNotification and NSWorkspace.screensDidSleepNotification.

- Place search uses MKLocalSearchCompleter, Open at Login uses SMAppService.mainApp.

- No Xcode project. build.sh calls swiftc per architecture and lipo's them into a universal binary. GitHub Actions builds the DMG and also launches the real app to take the README screenshots.

Where I'd like opinions:

  1. Is a WKWebView + WebGL renderer a reasonable choice here, or would you go Metal/SceneKit directly? WebGL made the shaders easy to iterate on and also let me reuse the renderer on the website, but I'm curious about the overhead others have seen.
  2. Is there a more reliable signal than occlusionState for "nobody can see the desktop right now"? It works for me, but I'd like to know if there are cases where it lies.
  3. Anything you'd watch out for with desktop-level windows on newer macOS versions?

It's MIT licensed and macOS 13+. I built it with some help from AI, and I'm happy to go into detail on any part.

https://github.com/Hensobo/earth-now

Short demo video: https://youtu.be/Ov-Rup8pm14


r/macosprogramming • • 6h ago

SmoothWheel: open-source mouse-wheel smoothing in Swift and AppKit

2 Upvotes

I’m the developer of SmoothWheel, a free, MIT-licensed menu-bar utility for smoothing third-party mouse wheels on macOS. I started it because I wanted my Razer mouse to feel more comfortable on a Mac.

It supports vertical and horizontal scrolling, three presets, separate speed and smoothing controls, reverse direction, per-app exclusions, and holding Option to bypass smoothing. Continuous trackpad events pass through unchanged. There’s a built-in playground for trying the settings.

The app is built with Swift and AppKit, with no third-party runtime dependencies, account, app analytics, or network requests.

The latest update, v0.3.17, brings significant improvements to scrolling behavior and app exclusions.

Website: https://smoothwheel.vercel.app/

Source: https://github.com/AntonMazur/SmoothWheel

The current download is for Apple Silicon and targets macOS 13+. Accessibility permission is required.

I’d welcome feedback on the scrolling experience and reports from other mouse models.


r/macosprogramming • • 6h ago

MockMini: a tiny, auditable proxy core for macOS written from scratch (~2,600 lines of C + Swift, Apache-2.0)

1 Upvotes

MockMini is a small, auditable proxy core in C and Swift. It speaks Shadowsocks AEAD, VMess, Trojan and VLESS over TCP, TLS or WebSocket, on top of its own bounded userspace TCP/IP endpoint that you feed from utun on macOS 13+.

  • Small enough to review: about 2,600 lines in total. Not based on mihomo, Clash, sing-box, gVisor or WireGuard; no Go runtime, no vendored stack.
  • Tested hard: a stateful, checksum-aware fuzzer gets ~99% line coverage of the packet engine; CI runs ASan/UBSan and libFuzzer on Linux and macOS, plus interop tests against real Xray servers for every protocol.
  • Permissive license: Apache-2.0, so you can ship it in open- or closed-source apps. Add it with Swift Package Manager.

Known limits (1024 flows, no SACK/ICMP, no Reality or gRPC) are listed honestly in the README. v0.1.0 is the first tagged release. Reviews and bug reports are very welcome.

Repo: https://github.com/yezicheng2011/mockmini


r/macosprogramming • • 21h ago

Gestione della riduzione a icona della finestra

Thumbnail github.com
1 Upvotes

Ciao, sono passato da poco a un MacBook Pro e ho notato che le gesture possono fare molte cose, ma non ne ho trovata nessuna per ridurre a icona la finestra selezionata. Così, l'ingegnere del software che è in me ha deciso di usare il resto della serata per programmare una semplice app che permette di ridurre a icona la finestra su cui si sta lavorando con uno swipe a tre dita verso il basso sul trackpad. Se volete scaricarla, ecco il link al repository GitHub, è gratuita. Ciao!