#icons #freedesktop #gui

freedesktop-icons-greedy

A Freedesktop Icons lookup crate

3 releases

0.2.6 Jul 25, 2023
0.2.5 Jul 25, 2023
0.2.4 Jul 25, 2023

#22 in #freedesktop

MIT license

34KB
762 lines

freedesktop-icons-greedy

A fork of freedesktop-icons that resolves icons even when the theme doesn't have an index.

use freedesktop_icons_greedy::lookup;

let icon = lookup("firefox")
    .with_greed()
    .find();

lib.rs:

freedesktop-icons

This crate provides a freedesktop icon lookup implementation.

It exposes a single lookup function to find icons based on their name, theme, size and scale.

Example

Simple lookup:

The following snippet get an icon from the default 'hicolor' theme with the default scale (1) and the default size (24).

use freedesktop_icons_greedy::lookup;

let icon = lookup("firefox").find();

Complex lookup:

If you have specific requirements for your lookup you can use the provided builder functions:

use freedesktop_icons_greedy::lookup;

let icon = lookup("firefox")
    .with_size(48)
    .with_scale(2)
    .with_theme("Arc")
    .find();

Cache:

If your application is going to repeat the same icon lookups multiple times you can use the internal cache to improve performance.

use freedesktop_icons_greedy::lookup;

let icon = lookup("firefox")
    .with_size(48)
    .with_scale(2)
    .with_theme("Arc")
    .with_cache()
    .find();

Dependencies

~2–10MB
~92K SLoC