Files
fastfetch/src/modules/locale.c
T

35 lines
902 B
C
Raw Normal View History

2021-02-18 22:25:36 +01:00
#include "fastfetch.h"
2021-02-27 18:30:05 +01:00
void ffPrintLocale(FFinstance* instance)
2021-02-18 22:25:36 +01:00
{
2021-02-27 18:30:05 +01:00
if(ffPrintCachedValue(instance, "Locale"))
2021-02-22 16:52:51 +01:00
return;
2021-03-19 20:57:07 +01:00
char localeCode[256];
ffParsePropFile("/etc/locale.conf", "LANG=%[^\n]", localeCode);
if(localeCode[0] == '\0' && ffStrbufIsEmpty(&instance->config.localeFormat))
2021-02-19 16:23:41 +01:00
{
2021-02-27 18:30:05 +01:00
ffPrintError(instance, "Locale", "\"LANG=%[^\\n]\" not found in \"/etc/locale.conf\"");
2021-02-19 16:23:41 +01:00
return;
}
2021-02-18 22:25:36 +01:00
2021-03-19 20:57:07 +01:00
ffPrintLogoAndKey(instance, "Locale");
FFstrbuf locale;
ffStrbufInit(&locale);
if(ffStrbufIsEmpty(&instance->config.localeFormat))
{
ffStrbufSetS(&locale, localeCode);
}
else
{
ffParseFormatString(&locale, &instance->config.localeFormat, 1,
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, localeCode}
);
}
ffPrintAndSaveCachedValue(instance, "Locale", locale.chars);
ffStrbufDestroy(&locale);
2021-02-18 22:25:36 +01:00
}