Skip to content

Commit e4a6bf1

Browse files
committed
Terminal: support kgx (gnome console)
Fix #577
1 parent 276e22f commit e4a6bf1

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

src/detection/terminalfont/terminalfont_linux.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ static const char* getSystemMonospaceFont(void)
2727
return ffSettingsGet("/org/gnome/desktop/interface/monospace-font-name", "org.gnome.desktop.interface", NULL, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue;
2828
}
2929

30+
static void detectKgx(FFTerminalFontResult* terminalFont)
31+
{
32+
// kgx (gnome terminal) doesn't support profiles
33+
if(!ffSettingsGet("/org/gnome/Console/use-system-font", "org.gnome.Console", NULL, "use-system-font", FF_VARIANT_TYPE_BOOL).boolValue)
34+
{
35+
FF_AUTO_FREE const char* fontName = ffSettingsGet("/org/gnome/Console/custom-font", "org.gnome.Console", NULL, "custom-font", FF_VARIANT_TYPE_STRING).strValue;
36+
if(ffStrSet(fontName))
37+
ffFontInitPango(&terminalFont->font, fontName);
38+
else
39+
ffStrbufAppendF(&terminalFont->error, "Couldn't get terminal font from GSettings (org.gnome.Console::custom-font)");
40+
}
41+
else
42+
{
43+
FF_AUTO_FREE const char* fontName = getSystemMonospaceFont();
44+
if(ffStrSet(fontName))
45+
ffFontInitPango(&terminalFont->font, fontName);
46+
else
47+
ffStrbufAppendS(&terminalFont->error, "Could't get system monospace font name from GSettings / DConf");
48+
}
49+
}
50+
3051
static void detectFromGSettings(const char* profilePath, const char* profileList, const char* profile, const char* defaultProfileKey, FFTerminalFontResult* terminalFont)
3152
{
3253
FF_AUTO_FREE const char* defaultProfile = ffSettingsGetGSettings(profileList, NULL, defaultProfileKey, FF_VARIANT_TYPE_STRING).strValue;
@@ -51,7 +72,7 @@ static void detectFromGSettings(const char* profilePath, const char* profileList
5172
}
5273
else
5374
{
54-
const char* fontName = getSystemMonospaceFont();
75+
FF_AUTO_FREE const char* fontName = getSystemMonospaceFont();
5576
if(ffStrSet(fontName))
5677
ffFontInitPango(&terminalFont->font, fontName);
5778
else
@@ -243,6 +264,8 @@ void ffDetectTerminalFontPlatform(const FFTerminalShellResult* terminalShell, FF
243264
detectFromGSettings("/com/gexperts/Tilix/profiles/", "com.gexperts.Tilix.ProfilesList", "com.gexperts.Tilix.Profile", "default", terminalFont);
244265
else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "gnome-terminal-"))
245266
detectFromGSettings("/org/gnome/terminal/legacy/profiles:/:", "org.gnome.Terminal.ProfilesList", "org.gnome.Terminal.Legacy.Profile", "default", terminalFont);
267+
else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "kgx"))
268+
detectKgx(terminalFont);
246269
else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "mate-terminal"))
247270
detectFromGSettings("/org/mate/terminal/profiles/", "org.mate.terminal.global", "org.mate.terminal.profile", "default-profile", terminalFont);
248271
else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "deepin-terminal"))

src/detection/terminalshell/terminalshell.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,20 @@ FF_MAYBE_UNUSED static bool getTerminalVersionGnome(FFstrbuf* version)
206206
return true;
207207
}
208208

209+
FF_MAYBE_UNUSED static bool getTerminalVersionKgx(FFstrbuf* version)
210+
{
211+
if(ffProcessAppendStdOut(version, (char* const[]){
212+
"gnome-terminal",
213+
"--version",
214+
NULL
215+
})) return false;
216+
217+
//# KGX 45.0 using VTE 0.74.0 +BIDI +GNUTLS +ICU +SYSTEMD
218+
ffStrbufSubstrAfterFirstS(version, "KGX ");
219+
ffStrbufSubstrBeforeFirstC(version, ' ');
220+
return true;
221+
}
222+
209223
FF_MAYBE_UNUSED static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* version)
210224
{
211225
const char* konsoleVersion = getenv("KONSOLE_VERSION");

src/detection/terminalshell/terminalshell_linux.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,9 @@ const FFTerminalShellResult* ffDetectTerminalShell()
385385
#elif defined(__linux__) || defined(__FreeBSD__)
386386

387387
else if(ffStrbufStartsWithS(&result.terminalProcessName, "gnome-terminal-"))
388-
ffStrbufInitStatic(&result.terminalPrettyName, "gnome-terminal");
388+
ffStrbufInitStatic(&result.terminalPrettyName, "GNOME Terminal");
389+
else if(ffStrbufStartsWithS(&result.terminalProcessName, "kgx"))
390+
ffStrbufInitStatic(&result.terminalPrettyName, "GNOME Console");
389391

390392
#elif defined(__APPLE__)
391393

0 commit comments

Comments
 (0)