Skip to content

Commit b33692a

Browse files
committed
Logo: randomly select one if the logo source expands to multiple files
Fix #1426
1 parent e90c5cb commit b33692a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/common/io/io_unix.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "io.h"
22
#include "fastfetch.h"
33
#include "util/stringUtils.h"
4+
#include "common/time.h"
45

56
#include <fcntl.h>
67
#include <termios.h>
@@ -145,10 +146,10 @@ bool ffPathExpandEnv(FF_MAYBE_UNUSED const char* in, FF_MAYBE_UNUSED FFstrbuf* o
145146
if (wordexp(in, &exp, 0) != 0)
146147
return false;
147148

148-
if (exp.we_wordc == 1)
149+
if (exp.we_wordc >= 1)
149150
{
150151
result = true;
151-
ffStrbufSetS(out, exp.we_wordv[0]);
152+
ffStrbufSetS(out, exp.we_wordv[exp.we_wordc > 1 ? ffTimeGetNow() % exp.we_wordc : 0]);
152153
}
153154

154155
wordfree(&exp);
@@ -159,10 +160,10 @@ bool ffPathExpandEnv(FF_MAYBE_UNUSED const char* in, FF_MAYBE_UNUSED FFstrbuf* o
159160
if (glob(in, GLOB_NOSORT | GLOB_TILDE, NULL, &gb) != 0)
160161
return false;
161162

162-
if (gb.gl_matchc == 1)
163+
if (gb.gl_matchc >= 1)
163164
{
164165
result = true;
165-
ffStrbufSetS(out, gb.gl_pathv[0]);
166+
ffStrbufSetS(out, gb.gl_pathv[gb.gl_matchc > 1 ? ffTimeGetNow() % gb.gl_matchc : 0]);
166167
}
167168

168169
globfree(&gb);

0 commit comments

Comments
 (0)