v0.25.4Swift · .NET · Kotlin · MIT
Building blocks for menu bar, tray and phone apps
The parts every little desktop or phone app needs and nobody wants to write twice: a reminder scheduler, permission-free system signals, app-shell plumbing and, for a desk companion, a character that talks and knows when to be quiet. Swift for macOS and iOS, .NET for Windows, Kotlin for Android.
.package(url: "https://github.com/vmihalachi/laching", exact: "0.25.4")
https://github.com/vmihalachi/laching
dotnet add package Laching.Core
git submodule add https://github.com/vmihalachi/laching laching
import LachingCore
import LachingSystem
let scheduler = ReminderScheduler(
config: SchedulerConfig(
interval: 45 * 60,
quietHours: [12]
),
clock: SystemClock(),
idle: SystemIdleTimeProvider(),
// Mic or camera in use: hold the reminder.
busy: SystemBusyStateProvider()
)
// Call every 20 s or so.
if scheduler.tick() == .remind {
showBreak()
}
using Laching.Core.Scheduling;
using Laching.Windows.System;
var scheduler = new ReminderScheduler(
new SchedulerConfig {
IntervalSeconds = 45 * 60,
QuietHours = new HashSet<int> { 12 },
},
new SystemClock(),
new SystemIdleTimeProvider(),
// Mic or camera in use: hold the reminder.
new SystemBusyStateProvider());
// Call every 20 s or so.
if (scheduler.Tick() == SchedulerDecision.Remind)
ShowBreak();
import laching.core.scheduling.*
val scheduler = ReminderScheduler(
config = SchedulerConfig(
intervalSeconds = 45.0 * 60,
quietHours = setOf(12),
),
clock = SystemClock,
// A phone has no idle reading, and busy
// defaults to NeverBusy.
idle = { 0.0 },
)
// Call when the reminder alarm wakes the app.
if (scheduler.tick() == SchedulerDecision.REMIND) {
showBreak()
}
Never prompts
Every system signal reads device and window state. Nothing opens the camera or microphone, nothing asks for Accessibility, nothing needs an entitlement you would have to explain.
Never phones home
No network code in the app packages and modules: no analytics, no update checks, no telemetry; only the platform's own store talks to its service. The Swift package has no dependencies at all.
One behavior, three languages
The Swift code is the reference. JSON vectors generated from it are replayed by the C# port, and the scheduler's by the Kotlin port, so they cannot quietly drift.
What's inside
Seven Swift products, six NuGet packages and three Kotlin modules. Take the pure logic alone, the whole shell, or the companion on top.
LachingCoreLaching.Corelaching.coreScheduling and pure logic
An interval timer with active hours and weekdays, quiet hours, an idle reset ("you were away, the timer restarts"), a hold while the user is busy with a grace period after, snooze, "after my next call" and pause. Runs on an injected clock, so it builds and tests anywhere Swift, .NET or Kotlin runs. Swift on Apple platforms and Kotlin also have the drawing math: SVG path sampling, keyframes, polylines and a hand-drawn wobble. It has no C# port.
ReminderScheduler SchedulerConfig Clock IdleTimeProvider BusyStateProvider SplitMix64 SVGPath Wobble
LachingCompanionLaching.CompanionA desk companion's core
A phrase bank and picker (lines, jokes told in beats, tunes; scoped by skin, flavor and language), chatter cadence, quiet rules and mood, write-through settings your app extends, a coordinator that replays a whole day from a seed, desktop presence, skins, and a rig that animates vector or painted-layer character art. Your app brings the lines, skins and palette. Pure, so it builds and tests anywhere.
PhraseBank PhrasePicker QuietRules CompanionSettings CompanionCoordinator SkinCatalog RiggedCharacter
LachingSystemLaching.WindowsSystem signals
Idle time since the last input. Whether another app is using the camera or microphone. Full-screen apps, power source and battery level, output muted and route, screen locked, light and dark appearance. Each exposes a current value and a change callback.
SystemIdleTimeProvider SystemBusyStateProvider SystemPowerSource SystemAudioOutput ScreenLockWatcher AppearanceWatcher
LachingShellLaching.Windowslaching.androidApp shell
A window manager that shows the Dock icon only while a window is open, a login item toggle and "was I launched at login?", notifications with categories and actions, a floating desktop window for a pet or a sticky note, a native tray icon and menu, and single-instance startup. On the Mac also a status item with a popover and an animated glyph, and speech: the system voice or recorded clips, jokes told in beats, chimes. On Windows those come with the companion shell, below. On the phone: notifications on iOS, and on Android the alarm that wakes the app for the next reminder, the reminder notification, reduce motion, settings in SharedPreferences and a screenshot run.
WindowManager NotificationPoster LoginItem FloatingWindow StatusItemController SpeechSequencer TrayIconHost SingleInstance ReminderAlarms
LachingCompanionUILaching.Companion.Shell + Laching.Windows.Companion The companion on screen
The character view (vector and image parts), the character and its speech bubble on the desktop, the menu bar or tray glyph, delivery through bubble, voice, chime and notification, the system signals gathered into one snapshot, a palette your app sets, and a screenshot mode. And the shell your app subclasses: the model that runs the day, its delegate and menus, the Settings rows, the Support window and a screenshot script, every word passed in by your app. On Windows the logic is its own package, tested on any OS, and the WinUI 3 half draws it.
CharacterView CharacterCanvas DesktopCompanion DeliveryPerformer SignalHub CompanionPalette CompanionAppModel SupportWindow ScreenshotScript
LachingStoreLaching.Core + Laching.Windowslaching.core + laching.androidPurchases
A store for one-time unlockables and tips, on StoreKit 2 on the Mac and iPhone, the Microsoft Store on Windows and Google Play Billing on Android, with the backend behind a protocol so your tests use a mock. And when an app may ask for a review: once, and never again after.
PurchaseStore ProductCatalog StoreBackend StoreContextBackend PlayBillingBackend ReviewLifecycle
LachingTestingLaching.Testinglaching.testingFakes, fixtures and vectors for your tests
A fake for every protocol, a fixture phrase bank and skins, and the conformance generators and replays: your app's Swift tests write its own companion vectors from the standard case lists plus its own, its .NET tests replay them. The Kotlin module has the fakes and the helpers that find and read the vectors.
MockClock MockIdle MockBusy MockStoreBackend ConformanceSuite CompanionVectors CompanionReplay
The package ships no strings, product ids or window lists. Your app passes them in, already localized.
Building a companion? tools/ has the scripts and agent skills that go with it: localization, phrase sync, recorded voices, character art, sounds, screenshots, the store listing and checks, and @laching/landing on npm for the landing page. You vendor them as a submodule and run them on your machine; none of them ship in your app.
Knows you're on a call. Never asks.
A break reminder that pops up mid-meeting gets uninstalled. Laching holds a due reminder while another app is using the camera or the microphone, and it finds out without ever opening a device, so there is no permission dialog and nothing for a reviewer to question.
If a device can't be read, it reads as not busy. Your app never blocks on a signal.
- macOS Microphone
- CoreAudio's list of processes using an input device.
- macOS Camera
- AVFoundation device state by default, CoreMediaIO for a sandboxed app without the camera entitlement, or off. The microphone alone catches nearly every call.
- Windows Camera and microphone
- The capability access consent store: Windows records when each app starts and stops using a device, and a start without a stop means it is in use now. No manifest capability needed.
- macOS, Windows Full screen
- A full-screen app, game or presentation holds the reminder too.
Proven the same on every side
Each scheduler and companion behavior is written down once, as JSON generated from the Swift code. XCTest checks the Swift side reproduces it, xUnit replays every vector against the C# port, and JUnit replays the scheduler's against the Kotlin port. A change on one side fails the others' tests.
conformance/scheduler/call-postpones-then-grace.json
A call holds a due reminder; it fires once the call has been over for the grace period.
- Scheduler starts with a 45-minute interval. Next reminder 10:45.
- A call starts. At 10:45 the reminder is due: every tick returns
postpone, statuspostponed(call). - The call ends. The 30-second grace period runs.
-
remind. The next interval starts from here: 11:45:40.
Install
One tag per release: Swift and Kotlin take the tag, and the NuGet packages get a new version only when they changed, so theirs can trail it. Laching is 0.x, so pin an exact version: minor releases may change public types.
Swift Package Manager
macOS 14+ and iOS 17+, Swift 6 language mode, no dependencies
// Package.swift
.package(url: "https://github.com/vmihalachi/laching", exact: "0.25.4")
// then, per target
.product(name: "LachingCore", package: "laching")
Every product builds for the Mac.
Xcode, for iOS
iOS 17+, the same package
File › Add Package Dependencies, paste https://github.com/vmihalachi/laching, pick Exact Version and the latest release.
On iOS, LachingCore, LachingCompanion, LachingStore and LachingTesting build whole. From LachingShell come the notification poster, the feedback links, font registration and the layout check. LachingSystem and the companion's views are macOS only.
NuGet
.NET 11; every package an app ships is Native AOT compatible
dotnet add package Laching.Core
dotnet add package Laching.Companion # a desk companion
dotnet add package Laching.Companion.Shell # its shell, any OS
dotnet add package Laching.Windows # Windows 11
dotnet add package Laching.Windows.Companion # WinUI 3
dotnet add package Laching.Testing # test projects
Laching.Core, Laching.Companion and Laching.Companion.Shell build anywhere .NET runs. Laching.Windows adds the tray, idle and busy services, and Laching.Windows.Companion a companion app's whole shell on WinUI 3, with Laching.Companion.Shell under it. Those two need Windows 11 (net11.0-windows10.0.22000.0).
Gradle, for Android
Android 8+ (API 26), JDK 17; not on Maven
// android/settings.gradle.kts, with laching/ a submodule at the repo root
includeBuild("../laching/kotlin") {
dependencySubstitution {
substitute(module("laching:core"))
.using(project(":core"))
substitute(module("laching:android"))
.using(project(":android"))
}
}
// then, per module
implementation("laching:core")
The app's build includes the Kotlin modules from the submodule, checked out at the release's tag. laching.core and laching.testing are plain Kotlin on the JVM, so their tests run on any machine; laching.android is the Android library. docs/getting-started.md has the whole setup.
And for the website: Laching.Web
Six NuGet packages for small ASP.NET Core and Blazor sites on Azure Container Apps behind Cloudflare. They share nothing with the app packages, and no app here uses them; Adjudeca runs on them.
.NET 11. One version for all six, which moves only in a Laching release that changed them. web/README.md has the details.
dotnet add package Laching.Web.AspNetCore
dotnet add package Laching.Web.Jobs
Laching.Web.AspNetCore- The Cloudflare origin check, security headers with a per-request CSP nonce, and shared-cache headers for public pages.
Laching.Web.Jobs- A job table in PostgreSQL: enqueued with the change that caused it, run once across replicas, retried with backoff.
Laching.Web.Cloudflare- Turnstile behind a human check, and cache purges.
Laching.Web.Aspire- Ingress that only Cloudflare reaches, and a job that runs before the apps roll out.
Laching.Web.Tailwind- Tailwind v4 in
dotnet build, without Node. Laching.Web.Images- Uploads: PNG, JPEG and WebP recognized, a size limit, re-encoding to WebP or JPEG.
Used by
Laching was extracted from mybackhurts, which ships it, and sunnysays, in development, whose character skeleton became the companion layer. Mister Pagliacci is built on that layer too.
mybackhurts
Posture and break reminders for macOS, iPhone and iPad, Windows and Android
The first app to use Laching. Its scheduler, system signals and shell plumbing were generalized into the package, and its scheduler vectors were the first in the conformance suite.
sunnysays
A desk companion
A character that says lines on a cadence, knows when to be quiet, stands on the desktop and speaks with recorded voices. Everything under the character was generalized into the companion layer and its tools. In development.
Mister Pagliacci
A clown who tells jokes from the Mac menu bar or the Windows notification area
A companion app built on the companion layer from the start: his jokes, skins and recorded voice are his own, the mechanism is Laching's. In development.