Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No images renderd for icons #48

Open
WhyNotHugo opened this issue Feb 19, 2024 · 5 comments
Open

No images renderd for icons #48

WhyNotHugo opened this issue Feb 19, 2024 · 5 comments

Comments

@WhyNotHugo
Copy link

First of all, I'll clarify that I'm not using cosmic desktop; I'm trying to use cosmic-files under swaywm.

I'm trying out cosmic-files, and files don't render icons. The console output reads lots of lines like:

[2024-02-19T18:47:26Z WARN  cosmic_files::mime_icon] failed to get icon for MimeIconKey { path: "/home/hugo/downloads/Untitled.svg", size: 32 }: (icon not found, (Error type: IoError)

A quick glace at the code indicates that this is in src/mime_icon.rs, MimeIconCache::get calls systemicons::get_icon. I looked at its code and it seems to use Gtk under the hood. I'm using nemo (gtk3) as a file manager and icons for it render fine, so I'm fairly certain that a theme is properly installed and configured.

@WhyNotHugo
Copy link
Author

Huh, running the example from https://github.com/uriegel/systemicons/ fails, so maybe the bug is not specific to this crate?

Any special dependency that I should keep in mind in this context?

@WhyNotHugo
Copy link
Author

Huh, running the example from https://github.com/uriegel/systemicons/ fails, so maybe the bug is not specific to this crate?

The example's failure seem unrelated, since it's actually SEGFAULT'ing.

@joshuamegnauth54
Copy link
Contributor

joshuamegnauth54 commented Mar 28, 2024

I'm able to replicate this on my Sway machine too. COSMIC Files is no longer using the crate above but instead using features exposed by libcosmic directly. libcosmic is using freedesktop-icons instead of the (likely unmaintained?) crate above.

In any case, I tested all of this with a quick program that you can try too:

use std::{fs, path::Path};

use cosmic::widget::icon;
use xdg_mime::SharedMimeInfo;

fn main() {
    let path_arg = std::env::args().nth(1).unwrap();
    let path = Path::new(&path_arg);
    let mime_info = SharedMimeInfo::new();

    let mimes = if path.is_file() {
        mime_info.get_mime_types_from_file_name(&path_arg)
    } else {
        let mut mimes = vec![];
        for entry in fs::read_dir(path).unwrap() {
            let entry = entry.unwrap().path();
            let path = entry.to_str().unwrap();
            mimes.extend(mime_info.get_mime_types_from_file_name(path));
        }
        mimes
    };

    let theme = std::env::args().nth(2).unwrap_or_else(|| "Adwaita".into());
    for mime in mimes {
        println!("{mime}");
        for name in mime_info.lookup_icon_names(&mime) {
            let path = icon::from_name(name.clone()).path();
            println!("\t[libcosmic] {name} => {path:?}");

            let path = freedesktop_icons::lookup(&name).with_theme(&theme).find();
            println!("\t[freedesktop-icons] {name} => {path:?}")
        }
    }

    for theme in freedesktop_icons::list_themes() {
        println!("Theme: {theme}");
    }
}

And Cargo.toml:

[package]
name = "mimetest"
version = "0.1.0"
edition = "2021"

[dependencies]
freedesktop-icons = "0.2"
xdg-mime = "0.3"

[dependencies.libcosmic]
git = "https://github.com/pop-os/libcosmic.git"
features = ["desktop"]

I tried it on a few folders on my main computer. Every path was None. It's possible that we botched something in our Sway configs or how we launch it (e.g. missing XDG variables), but Thunar correctly renders icons and COSMIC Files works on a COSMIC session. I'll look into it.

EDIT: I updated the example code above. I made progress with it too.

joshuamegnauth54 added a commit to joshuamegnauth54/cosmic-files that referenced this issue Apr 4, 2024
Fixes: pop-os#48

This PR implements a last resort fallback to the default GTK icon theme
if COSMIC's theme is missing.

The user is warned if COSMIC's themes aren't available since a correct
installation should have them much like GTK should always have Adwaita.
@michalfita
Copy link

I can only say at the moment, I've run cosmic-files built on Unbuntu Noble (Gnome on Wayland) and no files' icons are present as well.

@mmstick
Copy link
Member

mmstick commented Aug 12, 2024

@michalfita Make sure you have installed the cosmic-icon-theme as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants