diff options
| author | Anser <rostgans@tutamail.com> | 2026-08-19 12:45:07 +0200 |
|---|---|---|
| committer | Anser <rostgans@tutamail.com> | 2026-08-19 21:48:52 +0200 |
| commit | 5c42cc27e8a5240b2c200b7162f700f791e958f7 (patch) | |
| tree | f55dbfd347722fa8c24bac4059ed94f101cd5ec2 /src/ascii.c | |
| parent | 4ec1b7740fa70e4433c9a47ff6cf59cd113fdc18 (diff) | |
added get_ascii_path - added global ascii folder in /opt/cfetch/
Diffstat (limited to 'src/ascii.c')
| -rw-r--r-- | src/ascii.c | 17 |
1 files changed, 16 insertions, 1 deletions
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 <stddef.h> #include <stdio.h> +#include <unistd.h> #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); |
