Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement (hacky) support for scalable icons #494

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions icon.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ static char *resolve_icon(struct mako_notification *notif) {
for (size_t i = 0; i < found_count; ++i) {
char *relative_path = icon_glob.gl_pathv[i];

if (!strcmp(relative_path+strlen(relative_path)-4, ".svg")) {
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe a better approach would be to check if the size subdir is named "scalable"?

Copy link
Author

@Tharre Tharre Jan 21, 2024

Choose a reason for hiding this comment

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

Would have to check for "scalable" and "symbolic", but yeah, possibly. There definitely seem to be themes that have more complex SVGs for bigger sizes, so not throwing away sizing information for them may be desirable.

On the other hand I don't know if other icon themes use different names for this; though spot checking the arch repos that does seem to be a common theme.

For my usecase this definitely works, if you want I can update this PR to this commit:
Tharre@d685b90

Copy link
Owner

Choose a reason for hiding this comment

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

Hm, right, I suppose that to do things the Right Way, we'd need to parse the theme .ini files... Although, maybe we should keep parsing the size if there are .svg files in a directory with a fixed size...

// Assume icon is scalable
free(icon_path);
icon_path = strdup(icon_glob.gl_pathv[i]);
break;
}

// Find the end of the current search path and walk to the next
// path component. Hopefully this will be the icon resolution
// subdirectory.
Expand Down