feat(apps): use linicon for freedesktop icon theme traversal
This commit is contained in:
@@ -16,4 +16,5 @@ tokio = { workspace = true }
|
|||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
|
linicon = "2.3.0"
|
||||||
xdg = "3"
|
xdg = "3"
|
||||||
|
|||||||
@@ -103,11 +103,21 @@ pub fn resolve_icon_path(name: &str) -> Option<String> {
|
|||||||
if name.starts_with('/') && Path::new(name).exists() {
|
if name.starts_with('/') && Path::new(name).exists() {
|
||||||
return Some(name.to_string());
|
return Some(name.to_string());
|
||||||
}
|
}
|
||||||
|
// Try linicon freedesktop theme traversal
|
||||||
|
let themes = ["hicolor", "Adwaita", "breeze", "Papirus"];
|
||||||
|
for theme in &themes {
|
||||||
|
if let Some(icon_path) = linicon::lookup_icon(name)
|
||||||
|
.from_theme(theme)
|
||||||
|
.with_size(48)
|
||||||
|
.find_map(|r| r.ok())
|
||||||
|
{
|
||||||
|
return Some(icon_path.path.to_string_lossy().into_owned());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Fallback to pixmaps
|
||||||
let candidates = [
|
let candidates = [
|
||||||
format!("/usr/share/pixmaps/{name}.png"),
|
format!("/usr/share/pixmaps/{name}.png"),
|
||||||
format!("/usr/share/pixmaps/{name}.svg"),
|
format!("/usr/share/pixmaps/{name}.svg"),
|
||||||
format!("/usr/share/icons/hicolor/48x48/apps/{name}.png"),
|
|
||||||
format!("/usr/share/icons/hicolor/scalable/apps/{name}.svg"),
|
|
||||||
];
|
];
|
||||||
candidates.into_iter().find(|p| Path::new(p).exists())
|
candidates.into_iter().find(|p| Path::new(p).exists())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user