GithubHelp home page GithubHelp logo

freedesktop-icons's Introduction

freedesktop-icons

crates.io-badge docrs-badge

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::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::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::lookup;

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

freedesktop-icons's People

Contributors

drakulix avatar oknozor avatar palladinium avatar wash2 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

freedesktop-icons's Issues

Minimum size

Currently, you can only specify a hard size. I want to be able to resize an image down if the theme only has a larger version, so having a minimum would be super useful.

Incorrectly skips theme directories containing no index.theme file

The specification says:

In at least one of the theme directories there must be a file called index.theme that describes the theme. The first index.theme found while searching the base directories in order is used. This file describes the general attributes of the theme.

However this library implements theme searching more like "In all of the theme directories".

For example ~/.local/share/icons/hicolor is skipped if it lacks a index.theme file even though /usr/share/icons/hicolor/index.theme exist.

Repo name typo

It seems there's a typo in github repo name (the crate name is fine):

  • freedestkop-icons
    ->
  • freedesktop-icons

Merge themes of same name in different directories

Currently get_all_themes overrides icon themes already present in the THEMES directory.

This is not correct, as users might override parts of a theme in their .local/share/icons folder. Additionally tools like flatpak extend the XDG_DATA_DIRS environment variable and provide application icons by extending the hicolor theme.

I would suggest THEMES value type to be of type Vec<Theme> instead and let lookup function test each of the returned themes of the same name. Would there be interest in a PR, that does this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.