Skip to content

Commit

Permalink
tweak: use Icon=... value from desktop file to search for the icon file
Browse files Browse the repository at this point in the history
  • Loading branch information
tdiam committed Oct 22, 2023
1 parent f4ddc01 commit bf62823
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/src/features/home/data/appimage_tools_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,13 @@ class AppimageToolsRepository {
String desktopfilename =
'aip_' + p.basenameWithoutExtension(newPath) + ".desktop";

String? desktopBasename;
String? iconName;

// Copy desktop file
try {
var desktopFile = Directory(squashDir)
.listSync()
.firstWhere((element) => p.extension(element.path) == ".desktop");
desktopBasename = p.basenameWithoutExtension(desktopFile.path);
await desktopFile
.moveFile(_localPathService.applicationsDir + desktopfilename);
String execPath = (await Process.run(
Expand All @@ -87,7 +86,7 @@ class AppimageToolsRepository {
.split(' ')[0]
.trim();

String iconName = (await Process.run(
iconName = (await Process.run(
"grep",
[
"^Icon=",
Expand Down Expand Up @@ -143,13 +142,13 @@ class AppimageToolsRepository {
["-r", "./usr/share/icons", localShareDir],
workingDirectory: squashDir,
));
} else if (desktopBasename != null) {
} else if (iconName != null) {
// No icons in {squashDir}/usr/share/icons, search in top-level folder
try {
var icon = Directory(squashDir)
.listSync()
.firstWhere((element) =>
p.basenameWithoutExtension(element.path) == desktopBasename
p.basenameWithoutExtension(element.path) == iconName
&& ['.png', '.svg'].contains(p.extension(element.path))
);

Expand All @@ -170,7 +169,7 @@ class AppimageToolsRepository {
sizeName = "scalable";
}

var iconFilename = "aip_${desktopBasename}_${checksum}${iconExt}";
var iconFilename = "aip_${iconName}_${checksum}${iconExt}";
icon.moveResolvedFile(
localShareDir + "/icons/hicolor/${sizeName}/apps/${iconFilename}"
);
Expand Down

0 comments on commit bf62823

Please sign in to comment.