FreeDesktop icon names
Typed Kotlin constants for the names defined by the FreeDesktop Icon Naming Specification.
freedesktop-icons provides the standard icon names from the
FreeDesktop Icon Naming Specification
as typed Kotlin constants. Linux icon themes resolve icons by name: instead of shipping
info.png, you reference dialog-information and the active theme renders its own version.
Other Nucleus Linux modules accept these constants wherever they take an icon.
Add the dependency
dependencies {
implementation("dev.nucleusframework:nucleus.freedesktop-icons:2.0.7")
}notification-linux and launcher-linux expose freedesktop-icons through api(). If you
already depend on either, the constants are on your classpath without a separate declaration.
Reference an icon
Each icon is a value of the sealed interface FreedesktopIcon. Pick a constant from the
category enum that matches the icon's context:
import dev.nucleusframework.freedesktop.icons.FreedesktopIcon
val info = FreedesktopIcon.Status.DIALOG_INFORMATION
val open = FreedesktopIcon.Action.DOCUMENT_OPEN
val printer = FreedesktopIcon.Device.PRINTERFor names outside the spec, a file path, or a file:// URI, use FreedesktopIcon.Custom:
val named = FreedesktopIcon.Custom("my-app-icon") // theme lookup by name
val path = FreedesktopIcon.Custom("/home/user/icon.png") // absolute path
val uri = FreedesktopIcon.Custom("file:///home/user/icon.png")FreedesktopIcon.flag builds a country flag name from an ISO 3166-1 alpha-2 code:
val flag = FreedesktopIcon.flag("fr") // FreedesktopIcon.Custom("flag-fr")How it works
Every constant carries a value string that holds its spec name — DIALOG_INFORMATION
resolves to "dialog-information". Custom and flag wrap arbitrary strings in the same
type, so any FreedesktopIcon is ultimately a name that a theme can look up.
When you hand a FreedesktopIcon to a Linux module — notifications, launcher quicklists — the
value is sent over D-Bus or written into a .desktop file as plain text. The system's active
icon theme turns that name into a concrete image at render time, so the app follows the user's
theme without shipping any bitmaps.
The constants are plain strings, so they compile on any platform. Off Linux they resolve to nothing visible, since no FreeDesktop theme is present.
API reference
Categories
FreedesktopIcon is a sealed interface. Each category is an enum whose entries map to spec
names; Custom is a value class for everything else.
| Category | Examples |
|---|---|
FreedesktopIcon.Action | DOCUMENT_OPEN, EDIT_COPY, MEDIA_PLAYBACK_START |
FreedesktopIcon.Animation | PROCESS_WORKING |
FreedesktopIcon.Application | ACCESSORIES_TEXT_EDITOR, MULTIMEDIA_VOLUME_CONTROL, UTILITIES_TERMINAL |
FreedesktopIcon.Category | APPLICATIONS_INTERNET, PREFERENCES_DESKTOP, SYSTEM_HELP |
FreedesktopIcon.Device | PRINTER, CAMERA_PHOTO, INPUT_KEYBOARD |
FreedesktopIcon.Emblem | IMPORTANT, FAVORITE, SHARED |
FreedesktopIcon.Emote | FACE_SMILE, FACE_SAD, FACE_WINK |
FreedesktopIcon.MimeType | TEXT_X_GENERIC, IMAGE_X_GENERIC, X_OFFICE_DOCUMENT |
FreedesktopIcon.Place | FOLDER, USER_HOME, NETWORK_SERVER |
FreedesktopIcon.Status | DIALOG_INFORMATION, DIALOG_WARNING, BATTERY_LOW |
FreedesktopIcon.Custom | value class for raw names, file paths, or file:// URIs |
Build a custom icon
FreedesktopIcon.Custom(value: String) is an inline value class. Its value is used verbatim,
whether it is a theme name, an absolute path, or a file:// URI.
Build a country flag
FreedesktopIcon.flag(countryCode: String) lowercases the code and returns
Custom("flag-<code>"):
FreedesktopIcon.flag("us") // Custom("flag-us")
FreedesktopIcon.flag("jp") // Custom("flag-jp")Notes
- Not every theme implements every icon name. Sticking to the canonical FreeDesktop set gives the highest chance of a match.
- Flag icons are not part of the FreeDesktop spec and depend on the theme shipping
flag-<code>names.
What's next
- Linux notifications — pass a
FreedesktopIconas the notification icon. - Linux launcher — reuse the same constants in
.desktopactions. - System tray — set a per-theme tray icon by name.