diff --git a/Cargo.toml b/Cargo.toml index a334204..05ea875 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,6 @@ serde_json = "1.0" tokio = { version = "1.48", features = ["rt-multi-thread", "macros"] } base64 = "0.22" freedesktop-desktop-entry = "0.8" -tux-icons = "0.4" +freedesktop-icons = "0.4.0" log = "0.4" simplelog = "0.12" diff --git a/src/main.rs b/src/main.rs index 3c6d24d..b5b2b5e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,12 @@ use std::fs; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use base64::{Engine as _, engine::general_purpose}; use freedesktop_desktop_entry::{DesktopEntry, Iter, default_paths}; +use freedesktop_icons::lookup; use openaction::*; use serde::{Deserialize, Serialize}; -use tux_icons::icon_fetcher::IconFetcher; fn is_flatpak() -> bool { use std::env::var; @@ -70,12 +70,19 @@ impl Action for LaunchAppAction { } } +fn get_icon_path_from_desktop_entry(desktop_entry_path: impl Into) -> Option { + let locales: &[&str] = &[]; + let entry = DesktopEntry::from_path(desktop_entry_path, locales.into()).ok()?; + let icon = entry.icon()?.to_owned(); + lookup(&icon).with_size(256).find() +} + async fn update_icon(instance: &Instance, settings: &LaunchAppSettings) -> OpenActionResult<()> { let icon = settings .app .as_deref() .filter(|s| !s.is_empty()) - .and_then(|path| IconFetcher::new().get_icon_path_from_desktop(path)) + .and_then(get_icon_path_from_desktop_entry) .and_then(|path| icon_to_base64(&path)) .unwrap_or_else(|| "icon".to_owned());