-
Notifications
You must be signed in to change notification settings - Fork 2
desktop
github-actions[bot] edited this page Jul 6, 2026
·
3 revisions
title: "Desktop" description: "worker-kmp on JVM Desktop — coroutine-based scheduler; no OS-level persistence, runs while process is alive."
worker-kmp on Desktop runs in two modes:
- In-process (default) — workers execute on a coroutine-backed scheduler inside the consumer app. Survives app lifetime but not app close.
-
OS-scheduler daemon (
cmp-worker-desktop-daemon) — a separate JVM daemon registered with the OS scheduler (Windows Task Scheduler / macOS launchd / Linux systemd-user) that runs work even when the consumer app is closed AND survives reboot.
- JDK 11+ (JDK 17+ recommended)
- Windows 10+ / macOS 11+ / Linux with systemd (for daemon mode)
// commonMain
api(libs.worker.kmp)
api(libs.worker.koin)
// jvmMain
api(libs.worker.desktop)
// (optional) OS-scheduler daemon for true-background
implementation(libs.worker.desktop.daemon)Worker wiring lives in your commonMain initApp() via WorkerKmpAuto.install() (see the
Quick start); the generated Desktop installer selects
desktopWorkManagerFactory() for you. The Desktop main() just calls initApp():
// desktopMain/main.kt
fun main() {
initApp() // commonMain initApp calls WorkerKmpAuto.install()
// ... start your Compose Desktop UI
}Desktop-specific WorkerConfig (e.g. a custom persistence dir) is supplied via a Koin binding —
see Configuration:
// commonMain (or desktopMain) module wired into initApp's startKoin:
single {
WorkerConfig(
logLevel = LogLevel.INFO,
desktopConfig = DesktopWorkManagerConfig(
persistenceDir = Path.of(System.getProperty("user.home"), ".myapp", "work"),
),
)
}For tasks that must run when the app is closed AND across reboots:
// At install/setup time, install the daemon:
DesktopDaemonInstaller.install(
appId = "com.example.myapp",
daemonJarPath = "/path/to/my-daemon.jar",
scheduleEveryMinutes = 15,
)
// At app start, point the factory at the daemon's persistence dir:
factory = desktopWorkManagerFactory(
DesktopDaemonConfig(daemonId = "com.example.myapp"),
)The installer writes:
-
Windows:
schtasks /createentry with TRIGGERMINUTE+ per-app working directory -
macOS:
~/Library/LaunchAgents/com.example.myapp.plistwithStartInterval -
Linux:
~/.config/systemd/user/com.example.myapp.timer+.serviceunits
Work queue state lives in DesktopWorkManagerConfig.persistenceDir (default
<user.home>/.workkmp/<app-id>/). The format is HMAC-protected .properties files —
see Security T1-T6.
- Platform API Matrix
- True Background Matrix — daemon mode vs other platforms
- Security — daemon integrity model + threat assumptions
Getting Started
Platform Support
Features
Operations
Release