Skip to content

Conversation

AnthonyLloydDotNet
Copy link

I am not a c++ dev - this was literally done because my cursor AppImage had no icon.

i know its not the best solution. probably going to have issues with some appimages packaging their icons in weird places

image

@TheAssassin
Copy link
Member

How did you write that code if you're not a C++ dev, though?

@AnthonyLloydDotNet
Copy link
Author

How did you write that code if you're not a C++ dev, though?

AI and linux knowledge lol

Copy link
Member

@TheAssassin TheAssassin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a first glance. This is quite a lot of code and it is not clear which part solves the problem, really.

Comment on lines +195 to +199
std::string baseName = desktopEntryIconName;
size_t lastDot = baseName.find_last_of('.');
if (lastDot != std::string::npos) {
baseName = baseName.substr(lastDot + 1);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit is duplicated at least three times. It should be a utility function.

Comment on lines +237 to +264
for (const auto& path : hicolorIconPaths) {
// Extract size from path like "usr/share/icons/hicolor/512x512/apps/"
std::string sizeStr;
size_t sizePos = path.find("/hicolor/");
if (sizePos != std::string::npos) {
sizePos = path.find('/', sizePos + 9);
if (sizePos != std::string::npos) {
size_t endPos = path.find('/', sizePos + 1);
if (endPos != std::string::npos) {
sizeStr = path.substr(sizePos + 1, endPos - sizePos - 1);
// Handle NxN format
size_t xPos = sizeStr.find('x');
if (xPos != std::string::npos) {
try {
int size = std::stoi(sizeStr.substr(0, xPos));
if (size > largestSize) {
largestSize = size;
largestIconPath = path;
}
} catch (...) {
// Skip invalid size format
continue;
}
}
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block of code is really hard to read and understand and does not actually validate the path structure. But given the amount of nested functionality, this also should be a separate function.

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 this pull request may close these issues.

2 participants