From b33692aa7d4521acaf0858ff0d58418dc20c72a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 5 Dec 2024 14:16:30 +0800 Subject: [PATCH] Logo: randomly select one if the logo source expands to multiple files Fix #1426 --- src/common/io/io_unix.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/common/io/io_unix.c b/src/common/io/io_unix.c index 4cb946d0e..69b6fbca6 100644 --- a/src/common/io/io_unix.c +++ b/src/common/io/io_unix.c @@ -1,6 +1,7 @@ #include "io.h" #include "fastfetch.h" #include "util/stringUtils.h" +#include "common/time.h" #include #include @@ -145,10 +146,10 @@ bool ffPathExpandEnv(FF_MAYBE_UNUSED const char* in, FF_MAYBE_UNUSED FFstrbuf* o if (wordexp(in, &exp, 0) != 0) return false; - if (exp.we_wordc == 1) + if (exp.we_wordc >= 1) { result = true; - ffStrbufSetS(out, exp.we_wordv[0]); + ffStrbufSetS(out, exp.we_wordv[exp.we_wordc > 1 ? ffTimeGetNow() % exp.we_wordc : 0]); } wordfree(&exp); @@ -159,10 +160,10 @@ bool ffPathExpandEnv(FF_MAYBE_UNUSED const char* in, FF_MAYBE_UNUSED FFstrbuf* o if (glob(in, GLOB_NOSORT | GLOB_TILDE, NULL, &gb) != 0) return false; - if (gb.gl_matchc == 1) + if (gb.gl_matchc >= 1) { result = true; - ffStrbufSetS(out, gb.gl_pathv[0]); + ffStrbufSetS(out, gb.gl_pathv[gb.gl_matchc > 1 ? ffTimeGetNow() % gb.gl_matchc : 0]); } globfree(&gb);