aboutsummaryrefslogtreecommitdiff
path: root/src/ascii.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ascii.c')
-rw-r--r--src/ascii.c17
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);