Nucleus
OS integrationDock and taskbar

Progress and attention

Show progress and attention requests on the Dock icon, the taskbar button, or the Linux launcher entry from Kotlin.

View as Markdown

Taskbar progress draws a progress bar and requests attention on the macOS Dock icon, the Windows taskbar button, or the Linux launcher entry. When the desktop does not support it, calls return false instead of throwing.

taskbar-progress-taomacOSWindowsLinuxGradle plugin: RecommendedWindow runtime: RequiredOn Linux, the progress attaches to the installed desktop entry.
taskbar-progressmacOSWindowsLinuxGradle plugin: RecommendedWindow runtime: Not neededOn Linux, the progress attaches to the installed desktop entry.

An export on macOS: the bar under the app's Dock icon fills with the window's progress, then disappears

Add the dependency

build.gradle.kts
dependencies {
    implementation("dev.nucleusframework:nucleus.taskbar-progress-tao:3.0.0")
}

A plain Compose Desktop or Swing host uses taskbar-progress alone. See Use the plain API.

Show progress from a window

DecoratedWindow(onCloseRequest = ::exitApplication) {
    val progress by download.progress.collectAsState()

    LaunchedEffect(progress) {
        if (progress < 1.0) nucleusWindow.showTaskbarProgress(progress)
        else nucleusWindow.hideTaskbarProgress()
    }
    DisposableEffect(Unit) {
        onDispose { nucleusWindow.hideTaskbarProgress() }
    }
}

The value is a fraction in 0.0..1.0. Clear it in onDispose so a stale bar does not outlive the screen that set it. showTaskbarIndeterminate(), showTaskbarError(), showTaskbarPaused(), requestTaskbarAttention() and stopTaskbarAttention() work the same way.

On macOS and Linux, progress belongs to the app, not the window: two windows share one indicator.

Inside composition, rememberTaoTaskbarProgress() returns a handle bound to the current window (null outside one): taskbar?.showProgress(progress).

Use the plain API

TaskbarProgress takes a java.awt.Window, for Compose Desktop and Swing hosts:

TaskbarProgress.showProgress(window, 0.75)
TaskbarProgress.showError(window, 1.0)
TaskbarProgress.hideProgress(window)
TaskbarProgress.requestAttention(window, TaskbarProgress.AttentionType.INFORMATIONAL)

Changed in 3.0

nucleusApplication windows have no AWT Window. Move those calls to the nucleusWindow extensions. See Migrate from 2.x.

Set the Linux desktop file

If .desktop detection fails, isAvailable() returns false. Set the name yourself:

TaskbarProgress.linuxDesktopFilename = "myapp.desktop"

API reference

nucleusWindow extensionTaskbarProgressEffect
showTaskbarProgress(value)showProgress(window, value)NORMAL at value
showTaskbarIndeterminate()showIndeterminate(window)INDETERMINATE
showTaskbarError(value = 1.0)showError(window, value)ERROR at value
showTaskbarPaused(value = 1.0)showPaused(window, value)PAUSED at value
hideTaskbarProgress()hideProgress(window)NO_PROGRESS
setTaskbarProgress(value) / setTaskbarState(state)setProgress / setStateFraction or state alone
requestTaskbarAttention(type) / stopTaskbarAttention()requestAttention / stopAttentionStart or cancel attention

TaskbarProgress also has isAvailable(), linuxDesktopFilename, and *ForHwnd variants for a raw Windows HWND.

StateWindowsmacOSLinux
INDETERMINATEPulsing barStatic barSame as NORMAL
NORMALGreenBlueAccent
ERRORRedRedPlain progress; add requestAttention
PAUSEDYellowYellowPlain progress
AttentionTypeWindowsmacOS
INFORMATIONALFlashes four timesBounces once
CRITICALFlashes until focusedBounces until activated

On Linux, both set the urgent flag.

What's next

Was this page helpful?
Edit on GitHub

Last updated on