[][src]Function linicon::lookup_icon

pub fn lookup_icon<'a>(
    theme_name: impl AsRef<str>,
    name: impl AsRef<str>,
    size: u16,
    scale: u16
) -> Result<IconIter<'a>>

Lookup and icons given a name, size, and scale and the name theme you want to look the icon up from.

As per the FreeDesktop Icon Theme specification, linicon will search for icon themes the the following directories in order:

  • $HOME/.icons
  • $XDG_DATA_DIRS/icons (each path in list followed by /icons)
  • /usr/share/pixmaps

If you need to specify additional search paths use lookup_icon_with_extra_paths

Returns

Returns an iterator over matching icons. The iterator will also iterate though matching icons in fallback themes after ones in the main theme are exhausted.

Errors

The function will return an error if:

  • The theme isn't installed/correctly
  • There is an error parsing the theme's index file The iterator may return an error if:
  • Finding a fallback theme fails The iterator will return stop after an error.

Examples

Find one icon

let firefox_icon = linicon::lookup_icon("Faenza", "wireshark", 64, 1)
    .unwrap()
    .next()
    .unwrap()
    .unwrap();
println!("{:?}", firefox_icon);

Get all icons

use linicon::lookup_icon;
let firefox_icons: Vec<_> = lookup_icon("Faenza", "wireshark", 64, 1)
    .unwrap()
    .collect();
println!("{:#?}", firefox_icons);