mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
TTY improvements
This commit is contained in:
+1
-1
@@ -31,7 +31,7 @@ void ffPrintShell(FFinstance* instance)
|
||||
ffStrbufAppendTransformS(&command, shellName != NULL ? shellName : shellPath, toupper);
|
||||
ffStrbufAppendS(&command, "_VERSION\"");
|
||||
|
||||
ffProcessGetStdOut(&version, (char* const[]){
|
||||
ffProcessAppendStdOut(&version, (char* const[]){
|
||||
shellPath,
|
||||
"-c",
|
||||
command.chars,
|
||||
|
||||
@@ -7,6 +7,18 @@
|
||||
#define FF_TERMINAL_MODULE_NAME "Terminal"
|
||||
#define FF_TERMINAL_NUM_FORMAT_ARGS 3
|
||||
|
||||
static inline void getTerminalFromEnv(FFTerminalResult* result)
|
||||
{
|
||||
char* term = getenv("TERM");
|
||||
|
||||
//TTY
|
||||
if(term == NULL || strcasecmp(term, "linux") == 0)
|
||||
term = ttyname(STDIN_FILENO);
|
||||
|
||||
ffStrbufSetS(&result->exeName, term);
|
||||
ffStrbufSetS(&result->processName, term);
|
||||
}
|
||||
|
||||
static void getTerminalName(FFinstance* instance, const char* pid, FFTerminalResult* result)
|
||||
{
|
||||
char statFile[234];
|
||||
@@ -76,6 +88,14 @@ const FFTerminalResult* ffDetectTerminal(FFinstance* instance)
|
||||
|
||||
getTerminalName(instance, ppid, &result);
|
||||
|
||||
// This is mainly used when running in TTY. It also provides an fallback to $TERM if we _somehow_ failed
|
||||
if(
|
||||
ffStrbufStartsWithIgnCaseS(&result.exeName, "login") ||
|
||||
ffStrbufIgnCaseCompS(&result.exeName, "systemd") == 0 ||
|
||||
ffStrbufIgnCaseCompS(&result.exeName, "init") == 0 ||
|
||||
ffStrbufIgnCaseCompS(&result.exeName, "(init)") == 0
|
||||
) getTerminalFromEnv(&result);
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
return &result;
|
||||
|
||||
@@ -71,12 +71,24 @@ static void printXFCE4Terminal(FFinstance* instance)
|
||||
|
||||
static void printTTY(FFinstance* instance)
|
||||
{
|
||||
char font[128];
|
||||
ffParsePropFile("/etc/vconsole.conf", "Font=%[^\n]", font);
|
||||
if(font[0] == '\0')
|
||||
strcpy(font, "hardware-supplied VGA font");
|
||||
FFstrbuf font;
|
||||
ffStrbufInit(&font);
|
||||
|
||||
printTerminalFont(instance, font);
|
||||
ffParsePropFile("/etc/vconsole.conf", "Font=%[^\n]", font.chars);
|
||||
ffStrbufRecalculateLength(&font);
|
||||
|
||||
if(font.length == 0)
|
||||
{
|
||||
ffStrbufAppendS(&font, "VGA default kernel font ");
|
||||
ffProcessAppendStdOut(&font, (char* const[]){
|
||||
"showconsolefont",
|
||||
"--info",
|
||||
NULL
|
||||
});
|
||||
}
|
||||
|
||||
printTerminalFont(instance, font.chars);
|
||||
ffStrbufDestroy(&font);
|
||||
}
|
||||
|
||||
void ffPrintTerminalFont(FFinstance* instance)
|
||||
@@ -93,8 +105,8 @@ void ffPrintTerminalFont(FFinstance* instance)
|
||||
printKonsole(instance);
|
||||
else if(ffStrbufIgnCaseCompS(&result->exeName, "xfce4-terminal") == 0)
|
||||
printXFCE4Terminal(instance);
|
||||
else if(ffStrbufStartsWithIgnCaseS(&result->exeName, "login"))
|
||||
else if(ffStrbufStartsWithIgnCaseS(&result->exeName, "/dev/tty"))
|
||||
printTTY(instance);
|
||||
else
|
||||
ffPrintError(instance, FF_TERMFONT_MODULE_NAME, 0, &instance->config.termFontKey, &instance->config.termFontFormat, FF_TERMFONT_NUM_FORMAT_ARGS, "Terminal Font", "Unknown terminal: %s", result->exeName.chars);
|
||||
ffPrintError(instance, FF_TERMFONT_MODULE_NAME, 0, &instance->config.termFontKey, &instance->config.termFontFormat, FF_TERMFONT_NUM_FORMAT_ARGS, "Unknown terminal: %s", result->exeName.chars);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user