# FreeDesktop icon names

Typed Kotlin constants for the names defined by the FreeDesktop Icon Naming Specification.

`freedesktop-icons` provides the names of the
[FreeDesktop Icon Naming Specification](https://specifications.freedesktop.org/icon-naming/latest/)
as typed Kotlin constants. You send `dialog-information` instead of shipping `info.png`, and the
user's Linux icon theme draws its own version.

## Add the dependency

```kotlin title="build.gradle.kts"
dependencies {
    implementation("dev.nucleusframework:nucleus.freedesktop-icons:3.0.0")
}
```

`notification-linux` and `launcher-linux` already bring it.

## Reference an icon

Pick the constant from the category enum that matches its context:

```kotlin
val info = FreedesktopIcon.Status.DIALOG_INFORMATION
val printer = FreedesktopIcon.Device.PRINTER

// A name outside the specification, an absolute path, or a file:// URI
val named = FreedesktopIcon.Custom("my-app-icon")
val path = FreedesktopIcon.Custom("/home/user/icon.png")

// Country flag from an ISO 3166-1 alpha-2 code
val flag = FreedesktopIcon.flag("FR") // Custom("flag-fr")
```

- Themes do not implement every name. Names from the core specification have the best chance of
  a match.
- Flag names are not part of the specification. They resolve only in themes that ship
  `flag-<code>` icons.
- The module compiles on every OS, but no theme resolves the names outside Linux.

## API reference

| 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)` | Inline value class, sent unchanged: theme name, absolute path or `file://` URI |
| `FreedesktopIcon.flag(countryCode)` | Lowercases the code and returns `Custom("flag-<code>")` |

Each constant holds its specification name in `value`.

## What's next

- [Notifications on Linux](/docs/os/notifications/linux): pass a `FreedesktopIcon` as the notification icon.
- [Linux launcher](/docs/os/dock-taskbar/linux): use the same constants in quicklist items.
- [SF Symbols](/docs/os/icons/sf-symbols): the typed symbol names for macOS.
