|
1 | 1 | #include "logo/logo.h" |
2 | 2 | #include "common/io/io.h" |
3 | 3 | #include "common/printing.h" |
| 4 | +#include "common/processing.h" |
4 | 5 | #include "detection/os/os.h" |
5 | 6 | #include "detection/terminalshell/terminalshell.h" |
6 | 7 | #include "util/textModifier.h" |
@@ -455,14 +456,13 @@ static inline void logoPrintDetected(FFLogoSize size) |
455 | 456 | logoPrintStruct(logoGetBuiltinDetected(size)); |
456 | 457 | } |
457 | 458 |
|
458 | | -static bool logoPrintData(bool doColorReplacement) |
| 459 | +static bool logoPrintData(bool doColorReplacement, FFstrbuf* source) |
459 | 460 | { |
460 | | - FFOptionsLogo* options = &instance.config.logo; |
461 | | - if(options->source.length == 0) |
| 461 | + if(source->length == 0) |
462 | 462 | return false; |
463 | 463 |
|
464 | 464 | logoApplyColors(logoGetBuiltinDetected(FF_LOGO_SIZE_NORMAL), doColorReplacement); |
465 | | - ffLogoPrintChars(options->source.chars, doColorReplacement); |
| 465 | + ffLogoPrintChars(source->chars, doColorReplacement); |
466 | 466 | return true; |
467 | 467 | } |
468 | 468 |
|
@@ -548,10 +548,36 @@ static bool logoTryKnownType(void) |
548 | 548 | return logoPrintBuiltinIfExists(&options->source, FF_LOGO_SIZE_SMALL); |
549 | 549 |
|
550 | 550 | if(options->type == FF_LOGO_TYPE_DATA) |
551 | | - return logoPrintData(true); |
| 551 | + return logoPrintData(true, &options->source); |
552 | 552 |
|
553 | 553 | if(options->type == FF_LOGO_TYPE_DATA_RAW) |
554 | | - return logoPrintData(false); |
| 554 | + return logoPrintData(false, &options->source); |
| 555 | + |
| 556 | + if(options->type == FF_LOGO_TYPE_COMMAND_RAW) |
| 557 | + { |
| 558 | + FF_STRBUF_AUTO_DESTROY source = ffStrbufCreate(); |
| 559 | + |
| 560 | + FFCommandOptions* commandOptions = &instance.config.modules.command; |
| 561 | + const char* error = ffProcessAppendStdOut(&source, commandOptions->param.length ? (char* const[]){ |
| 562 | + commandOptions->shell.chars, |
| 563 | + commandOptions->param.chars, |
| 564 | + options->source.chars, |
| 565 | + NULL |
| 566 | + } : (char* const[]){ |
| 567 | + commandOptions->shell.chars, |
| 568 | + options->source.chars, |
| 569 | + NULL |
| 570 | + }); |
| 571 | + |
| 572 | + if (error) |
| 573 | + { |
| 574 | + if (instance.config.display.showErrors) |
| 575 | + fprintf(stderr, "Logo: failed to execute command `%s`: %s\n", options->source.chars, error); |
| 576 | + return false; |
| 577 | + } |
| 578 | + |
| 579 | + return logoPrintData(false, &source); |
| 580 | + } |
555 | 581 |
|
556 | 582 | updateLogoPath(); //We sure have a file, resolve relative paths |
557 | 583 |
|
|
0 commit comments