icon-loader: support absolute icon names

This commit is contained in:
Johan Malm 2024-09-28 11:21:19 +01:00 committed by Johan Malm
parent be5472a840
commit 3394f191a4

View file

@ -118,7 +118,20 @@ out:
static int
process_abs_name(struct icon_ctx *ctx, const char *icon_name)
{
wlr_log(WLR_ERROR, "absolute paths not yet supported");
ctx->path = xstrdup(icon_name);
if (str_endswith(icon_name, ".png")) {
ctx->format = SFDO_ICON_FILE_FORMAT_PNG;
} else if (str_endswith(icon_name, ".svg")) {
ctx->format = SFDO_ICON_FILE_FORMAT_SVG;
} else if (str_endswith(icon_name, ".xpm")) {
ctx->format = SFDO_ICON_FILE_FORMAT_XPM;
} else {
goto err;
}
return 0;
err:
wlr_log(WLR_ERROR, "'%s' has invalid file extension", icon_name);
free(ctx->path);
return -1;
}