Files
fastfetch/src/modules/de.c
T

44 lines
1.2 KiB
C
Raw Normal View History

2021-03-19 20:57:07 +01:00
#include "fastfetch.h"
2021-04-15 18:59:26 +02:00
#define FF_DE_MODULE_NAME "DE"
2022-01-02 16:55:26 +01:00
#define FF_DE_NUM_FORMAT_ARGS 3
2021-03-19 20:57:07 +01:00
void ffPrintDesktopEnvironment(FFinstance* instance)
{
2022-01-10 14:41:34 +01:00
#ifdef __ANDROID__
2022-06-18 00:22:07 +02:00
ffPrintError(instance, FF_DE_MODULE_NAME, 0, &instance->config.de, "DE detection is not supported on Android");
2022-01-10 14:41:34 +01:00
return;
#endif
2022-01-02 16:55:26 +01:00
const FFDisplayServerResult* result = ffConnectDisplayServer(instance);
2021-03-19 20:57:07 +01:00
2021-05-07 16:16:23 +02:00
if(result->dePrettyName.length == 0)
2021-04-03 21:51:50 +02:00
{
2022-06-17 18:15:36 +02:00
ffPrintError(instance, FF_DE_MODULE_NAME, 0, &instance->config.de, "No DE found");
2021-04-03 21:51:50 +02:00
return;
}
2022-06-17 18:15:36 +02:00
if(instance->config.de.outputFormat.length == 0)
2021-03-19 20:57:07 +01:00
{
2022-06-17 18:15:36 +02:00
ffPrintLogoAndKey(instance, FF_DE_MODULE_NAME, 0, &instance->config.de.key);
2021-03-19 20:57:07 +01:00
2021-05-07 16:16:23 +02:00
ffStrbufWriteTo(&result->dePrettyName, 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
{
2022-06-17 18:15:36 +02:00
ffPrintFormat(instance, FF_DE_MODULE_NAME, 0, &instance->config.de, FF_DE_NUM_FORMAT_ARGS, (FFformatarg[]){
2021-05-01 13:03:30 +02:00
{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
}