diff --git a/src/modules/locale.c b/src/modules/locale.c index 5f1cfb936..cccc58cbc 100644 --- a/src/modules/locale.c +++ b/src/modules/locale.c @@ -1,3 +1,7 @@ +#include +#include +#include + #include "fastfetch.h" void ffPrintLocale(FFinstance* instance) @@ -5,13 +9,25 @@ void ffPrintLocale(FFinstance* instance) if(ffPrintCachedValue(instance, "Locale")) return; - char localeCode[256]; - ffParsePropFile("/etc/locale.conf", "LANG=%[^\n]", localeCode); + char localeCode[256]; + + FILE *fp; + fp = fopen("/etc/locale.conf", "r"); + + /* File does not exist */ + if (fp == NULL) { + strcpy(localeCode, getenv("LANG")); + } else { + ffParsePropFile("/etc/locale.conf", "LANG=%[^\n]", localeCode); + } + + /* if(localeCode[0] == '\0' && ffStrbufIsEmpty(&instance->config.localeFormat)) { ffPrintError(instance, "Locale", "\"LANG=%[^\\n]\" not found in \"/etc/locale.conf\""); return; } + */ ffPrintLogoAndKey(instance, "Locale"); @@ -32,4 +48,4 @@ void ffPrintLocale(FFinstance* instance) ffPrintAndSaveCachedValue(instance, "Locale", locale.chars); ffStrbufDestroy(&locale); -} \ No newline at end of file +}