diff options
| author | Naz <ndpm13@ch-naseem.com> | 2025-08-09 14:23:55 +0100 |
|---|---|---|
| committer | Naz <ndpm13@ch-naseem.com> | 2025-08-09 14:23:55 +0100 |
| commit | e5577490000f0f0ce99a047f320eefd0e7d3e5c7 (patch) | |
| tree | 4cacab5ff0f22463d804c49128b9c18ed7a35390 | |
| parent | e21127f9b26796cf2ff4380b8b42d2ebd8645a2a (diff) | |
✨feat: check all icon resolutions from 1024x1024 to 16x16
| -rw-r--r-- | src/appimage.rs | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/src/appimage.rs b/src/appimage.rs index 07fb990..1cb8f52 100644 --- a/src/appimage.rs +++ b/src/appimage.rs @@ -63,14 +63,7 @@ impl AppImage { // Extract icon Command::new(&self.file_path) .arg("--appimage-extract") - .arg("usr/share/icons/hicolor/512x512/apps/*.png") - .current_dir(&temp_dir) - .stdout(Stdio::null()) - .spawn()? - .wait()?; - Command::new(&self.file_path) - .arg("--appimage-extract") - .arg("usr/share/icons/hicolor/256x256/apps/*.png") + .arg("usr/share/icons/hicolor/*/apps/*.png") .current_dir(&temp_dir) .stdout(Stdio::null()) .spawn()? @@ -136,24 +129,27 @@ impl AppImage { )), ); + let icon_resolutions = [ + "1024", "720", "512", "256", "192", "128", "96", "72", "64", "48", "36", "32", "24", + "22", "16", + ]; + let mut icon_found = false; - if fs::try_exists(&squashfs.join("usr/share/icons/hicolor/512x512/apps")).await? { - let mut squashfs_icon_entries = - fs::read_dir(&squashfs.join("usr/share/icons/hicolor/512x512/apps")).await?; - while let Some(entry) = squashfs_icon_entries.next_entry().await? { - if entry.path().extension() == Some("png".as_ref()) { - fs::copy(entry.path(), &icon_path).await?; - icon_found = true; + for res in icon_resolutions { + let icon_dir = squashfs.join(format!("usr/share/icons/hicolor/{}x{}/apps", res, res)); + + if fs::try_exists(&icon_dir).await? { + let mut squashfs_icon_entries = fs::read_dir(&icon_dir).await?; + while let Some(entry) = squashfs_icon_entries.next_entry().await? { + if entry.path().extension() == Some("png".as_ref()) { + fs::copy(entry.path(), &icon_path).await?; + icon_found = true; + break; + } } - } - } else if fs::try_exists(&squashfs.join("usr/share/icons/hicolor/256x256/apps")).await? { - let mut squashfs_icon_entries = - fs::read_dir(&squashfs.join("usr/share/icons/hicolor/256x256/apps")).await?; - while let Some(entry) = squashfs_icon_entries.next_entry().await? { - if entry.path().extension() == Some("png".as_ref()) { - fs::copy(entry.path(), &icon_path).await?; - icon_found = true; + if icon_found { + break; } } } |
