Linux launcher
Set count badges, progress bars, urgency flags, and right-click quicklist menus on the Linux launcher from Kotlin.
launcher-linux draws count badges, progress bars, and urgency flags on your launcher icon, and
attaches a right-click quicklist. Unity, KDE Plasma, Plank, and budgie-panel support it. XFCE
without docklike-plugin does not: calls succeed and nothing is drawn.
launcher-linuxGradle plugin: RecommendedWindow runtime: Not neededNeeds the installed desktop entry that the plugin's deb and rpm packages provide.dependencies {
implementation("dev.nucleusframework:nucleus.launcher-linux:3.0.0")
}Set badges and progress
Build the launcher URI from your .desktop file name, which launcher-linux never guesses, then
set one property or several at once:
val appUri = LinuxLauncherEntry.appUri("myapp.desktop")
LinuxLauncherEntry.setCount(appUri, 42)
LinuxLauncherEntry.setProgress(appUri, 0.65) // 0.0..1.0
LinuxLauncherEntry.update(
appUri,
LauncherProperties(count = 5, countVisible = true, progress = 0.8, progressVisible = true),
)update sends every non-null field in one signal. For a cross-platform progress bar that finds
the .desktop file for you, use Taskbar progress.
Add a quicklist menu
Create a LinuxQuicklist on a D-Bus object path of your choice, install the menu, then point the
launcher entry at that path:
val quicklist = LinuxQuicklist("/com/example/MyApp/Menu")
quicklist.listener = LinuxQuicklist.Listener { id ->
when (id) {
1 -> openNewWindow()
8 -> exitApp()
}
}
quicklist.setMenu(listOf(
DbusmenuItem(id = 1, label = "New Window", icon = FreedesktopIcon.Action.WINDOW_NEW),
DbusmenuItem.separator(id = 2),
DbusmenuItem(id = 8, label = "Quit", disposition = DbusmenuItem.Disposition.ALERT),
))
LinuxLauncherEntry.update(appUri, LauncherProperties(quicklist = quicklist.objectPath))Icons come from freedesktop-icons. To change a toggle, call
setMenu(...) again with the new toggleState. On shutdown, unset the quicklist and release it:
LinuxLauncherEntry.update(appUri, LauncherProperties(quicklist = ""))
quicklist.dispose()Changed in 3.0
Quicklist clicks now arrive on the host UI thread instead of the Swing EDT. Under
nucleusApplication that is the thread Compose uses. See Threading
and Migrate from 2.x.
API reference
| Symbol | Notes |
|---|---|
LinuxLauncherEntry.isAvailable | false off Linux or when the native library failed to load. |
LinuxLauncherEntry.appUri(desktopFileId) | Builds the application://<id> URI. |
LinuxLauncherEntry.update(appUri, properties): Boolean | Sends every non-null field. |
setCount / clearCount / setProgress / clearProgress / setUrgent / setUpdating | Wrappers over update. |
registerQueryHandler(appUri) / unregister() | Answers the shell's queries for the entry state, then stops. |
LauncherProperties(count, countVisible, progress, progressVisible, urgent, quicklist, updating) | All nullable; null fields are skipped. quicklist = "" unsets the menu. |
LinuxQuicklist(objectPath) | listener, setMenu(items): Boolean, dispose(). |
LinuxQuicklist.Listener.onItemClicked(itemId: Int) | fun interface, called on the host UI thread. |
DbusmenuItem.separator(id) | A separator. |
DbusmenuItem fields: id (> 0), label (_ marks a mnemonic), icon (a
FreedesktopIcon), enabled, visible, type (STANDARD, SEPARATOR), toggleType (NONE,
CHECKBOX, RADIO), toggleState (-1 indeterminate, 0 unchecked, 1 checked), shortcut,
disposition (NORMAL, INFORMATIONAL, WARNING, ALERT), and children.
What's next
- Taskbar progress: cross-platform progress and attention.
- Freedesktop icons: symbolic icon names for menu items.
- macOS Dock menu: the Dock menu on macOS.
Last updated on