Progress and attention
Show progress and attention requests on the Dock icon, the taskbar button, or the Linux launcher entry from Kotlin.
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-taoGradle plugin: RecommendedWindow runtime: RequiredOn Linux, the progress attaches to the installed desktop entry.taskbar-progressGradle plugin: RecommendedWindow runtime: Not neededOn Linux, the progress attaches to the installed desktop entry.
Add the dependency
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 extension | TaskbarProgress | Effect |
|---|---|---|
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 / setState | Fraction or state alone |
requestTaskbarAttention(type) / stopTaskbarAttention() | requestAttention / stopAttention | Start or cancel attention |
TaskbarProgress also has isAvailable(), linuxDesktopFilename, and *ForHwnd variants for a
raw Windows HWND.
| State | Windows | macOS | Linux |
|---|---|---|---|
INDETERMINATE | Pulsing bar | Static bar | Same as NORMAL |
NORMAL | Green | Blue | Accent |
ERROR | Red | Red | Plain progress; add requestAttention |
PAUSED | Yellow | Yellow | Plain progress |
AttentionType | Windows | macOS |
|---|---|---|
INFORMATIONAL | Flashes four times | Bounces once |
CRITICAL | Flashes until focused | Bounces until activated |
On Linux, both set the urgent flag.
What's next
- Windows taskbar: overlay icons, jump lists, and thumbnail toolbars.
- Linux launcher: badges, urgency, and quicklists.
- macOS Dock menu: the Dock menu.
- Energy manager: keep the machine awake during long work.
Last updated on