From 5c42cc27e8a5240b2c200b7162f700f791e958f7 Mon Sep 17 00:00:00 2001 From: Anser Date: Wed, 19 Aug 2026 12:45:07 +0200 Subject: added get_ascii_path - added global ascii folder in /opt/cfetch/ --- src/ascii.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/ascii.c') diff --git a/src/ascii.c b/src/ascii.c index 0a2dc67..b199dd4 100644 --- a/src/ascii.c +++ b/src/ascii.c @@ -18,6 +18,7 @@ #include "../include/cfetch.h" #include #include +#include #define MAX_LOGOS 5 @@ -32,6 +33,20 @@ static const struct ascii_mapping_t ascii_mappings[] = {NULL, NULL} }; +char* get_ascii_path(void) +{ + char *path[] = { + "/opt/cfetch/ascii/", + "./ascii/" + }; + + for (size_t i = 0; i < (sizeof(path) / sizeof(path[0])) ; i++) { + if (access(path[i], F_OK) == 0) return path[i]; + } + + return NULL; +} + const char* get_ascii_name(const struct ascii_mapping_t *d_map, int art) { if (art >= MAX_LOGOS) { @@ -48,7 +63,7 @@ void print_ascii_art(struct system_info_t *info) { // get ascii name const char* name = get_ascii_name(ascii_mappings, info->ascii_art); - char* path = concat("ascii/", name); + char* path = concat(get_ascii_path(), name); if (info->debug == 1) { printf("path: %s\n", path); -- cgit v1.2.3