2021-02-18 22:25:36 +01:00
#include "fastfetch.h"
2022-07-25 13:15:01 +02:00
#include "common/printing.h"
2022-07-26 18:06:30 +02:00
#include "detection/terminalshell.h"
2021-02-18 22:25:36 +01:00
2021-04-28 19:53:30 +02:00
#include <string.h>
2021-04-15 18:59:26 +02:00
#define FF_TERMINAL_MODULE_NAME "Terminal"
#define FF_TERMINAL_NUM_FORMAT_ARGS 3
2021-03-11 17:21:18 +01:00
void ffPrintTerminal ( FFinstance * instance )
{
2021-06-14 23:22:14 +02:00
const FFTerminalShellResult * result = ffDetectTerminalShell ( instance );
2021-04-02 16:21:52 +02:00
2021-06-14 23:22:14 +02:00
if ( result -> terminalProcessName . length == 0 )
2021-04-03 21:51:50 +02:00
{
2022-06-17 18:15:36 +02:00
ffPrintError ( instance , FF_TERMINAL_MODULE_NAME , 0 , & instance -> config . terminal , "Couldn't detect terminal" );
2021-04-03 21:51:50 +02:00
return ;
}
2022-06-17 18:15:36 +02:00
if ( instance -> config . terminal . outputFormat . length == 0 )
2021-03-11 17:21:18 +01:00
{
2022-06-17 18:15:36 +02:00
ffPrintLogoAndKey ( instance , FF_TERMINAL_MODULE_NAME , 0 , & instance -> config . terminal . key );
2021-09-19 14:58:46 +02:00
2021-11-01 14:47:36 +01:00
if ( strncmp ( result -> terminalExeName , result -> terminalProcessName . chars , result -> terminalProcessName . length ) == 0 ) // if exeName starts with processName, print it. Otherwise print processName
2021-09-19 14:58:46 +02:00
puts ( result -> terminalExeName );
else
ffStrbufPutTo ( & result -> terminalProcessName , stdout );
2021-03-11 17:21:18 +01:00
}
else
{
2022-06-17 18:15:36 +02:00
ffPrintFormat ( instance , FF_TERMINAL_MODULE_NAME , 0 , & instance -> config . terminal , FF_TERMINAL_NUM_FORMAT_ARGS , ( FFformatarg []){
2021-06-14 23:22:14 +02:00
{ FF_FORMAT_ARG_TYPE_STRBUF , & result -> terminalProcessName },
{ FF_FORMAT_ARG_TYPE_STRBUF , & result -> terminalExe },
2021-10-25 13:31:25 +02:00
{ FF_FORMAT_ARG_TYPE_STRING , result -> terminalExeName }
2021-04-15 18:59:26 +02:00
});
2021-03-11 17:21:18 +01:00
}
2021-02-18 22:25:36 +01:00
}