2021-03-19 20:57:07 +01:00
|
|
|
#include "fastfetch.h"
|
|
|
|
|
|
2021-04-09 14:07:05 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
|
2021-04-15 18:59:26 +02:00
|
|
|
#define FF_DE_MODULE_NAME "DE"
|
2021-05-01 13:03:30 +02:00
|
|
|
#define FF_DE_NUM_FORMAT_ARGS 4
|
2021-03-19 20:57:07 +01:00
|
|
|
|
|
|
|
|
void ffPrintDesktopEnvironment(FFinstance* instance)
|
|
|
|
|
{
|
2021-05-01 13:03:30 +02:00
|
|
|
const FFWMDEResult* result = ffDetectWMDE(instance);
|
2021-03-19 20:57:07 +01:00
|
|
|
|
2021-05-01 13:03:30 +02:00
|
|
|
if(result->dePrettyName.length == 0 && result->sessionDesktop == NULL)
|
2021-04-03 21:51:50 +02:00
|
|
|
{
|
2021-05-01 13:03:30 +02:00
|
|
|
ffPrintError(instance, FF_DE_MODULE_NAME, 0, &instance->config.deKey, &instance->config.deFormat, FF_DE_NUM_FORMAT_ARGS, "No DE found");
|
2021-04-03 21:51:50 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-23 19:48:52 +01:00
|
|
|
if(instance->config.deFormat.length == 0)
|
2021-03-19 20:57:07 +01:00
|
|
|
{
|
2021-04-15 18:59:26 +02:00
|
|
|
ffPrintLogoAndKey(instance, FF_DE_MODULE_NAME, 0, &instance->config.deKey);
|
2021-03-19 20:57:07 +01:00
|
|
|
|
2021-05-01 13:03:30 +02:00
|
|
|
if(result->dePrettyName.length > 0)
|
|
|
|
|
ffStrbufWriteTo(&result->dePrettyName, stdout);
|
2021-04-25 21:32:35 +02:00
|
|
|
else
|
2021-05-01 13:03:30 +02:00
|
|
|
fputs(result->sessionDesktop, stdout);
|
2021-03-19 20:57:07 +01:00
|
|
|
|
2021-05-01 13:03:30 +02:00
|
|
|
if(result->deVersion.length > 0)
|
2021-04-25 21:32:35 +02:00
|
|
|
{
|
|
|
|
|
putchar(' ');
|
2021-05-01 13:03:30 +02:00
|
|
|
ffStrbufWriteTo(&result->deVersion, stdout);
|
2021-03-19 20:57:07 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-22 20:02:32 +01:00
|
|
|
putchar('\n');
|
2021-03-19 20:57:07 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-04-15 18:59:26 +02:00
|
|
|
ffPrintFormatString(instance, FF_DE_MODULE_NAME, 0, &instance->config.deKey, &instance->config.deFormat, NULL, FF_DE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
2021-05-01 13:03:30 +02:00
|
|
|
{FF_FORMAT_ARG_TYPE_STRING, result->sessionDesktop},
|
|
|
|
|
{FF_FORMAT_ARG_TYPE_STRBUF, &result->deProcessName},
|
|
|
|
|
{FF_FORMAT_ARG_TYPE_STRBUF, &result->dePrettyName},
|
|
|
|
|
{FF_FORMAT_ARG_TYPE_STRBUF, &result->deVersion}
|
2021-04-15 18:59:26 +02:00
|
|
|
});
|
2021-03-19 20:57:07 +01:00
|
|
|
}
|
2021-03-27 18:14:19 +01:00
|
|
|
}
|