TerminalFont (Linux): support xfce4-terminal 1.1.0+

Fixes #602
This commit is contained in:
李通洲 2023-11-01 09:39:24 +08:00
parent 761c649817
commit 494cc1493e
No known key found for this signature in database
GPG Key ID: 269AD4F5325A22A3
2 changed files with 23 additions and 4 deletions

View File

@ -22,6 +22,7 @@ Features:
* Support urxvt version detection (Terminal, Linux)
* Support st version detection (Terminal, Linux)
* Support st terminal font detection (TerminalFont, Linux)
* Support xfce4-terminal 1.1.0+ terminal font detection (TerminalFont, Linux)
* Add option `--migrate-config <?target-file-path>`
* Support Nvidia GPU temp and cuda core count detection via nvml. Use `--gpu-use-nvml` to enable it (GPU)
* Try supporting Wifi authentication type detection in macOS Sonoma. Please file a feature request if you get `to be supported (num)` with result of `/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | grep auth` (Wifi, macOS)

View File

@ -125,15 +125,33 @@ static void detectXFCETerminal(FFTerminalFontResult* terminalFont)
FF_STRBUF_AUTO_DESTROY useSysFont = ffStrbufCreate();
FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate();
ffParsePropFileConfigValues("xfce4/terminal/terminalrc", 2, (FFpropquery[]) {
{"FontUseSystem = ", &useSysFont},
{"FontName = ", &fontName}
const char* path = "xfce4/xfconf/xfce-perchannel-xml/xfce4-terminal.xml";
bool configFound = ffParsePropFileConfigValues(path, 2, (FFpropquery[]) {
{"<property name=\"font-use-system\" type=\"bool\" value=\"", &useSysFont},
{"<property name=\"font-name\" type=\"string\" value=\"", &fontName}
});
if (configFound)
{
ffStrbufSubstrBeforeLastC(&useSysFont, '"');
ffStrbufSubstrBeforeLastC(&fontName, '"');
}
else
{
path = "xfce4/terminal/terminalrc";
configFound = ffParsePropFileConfigValues(path, 2, (FFpropquery[]) {
{"FontUseSystem = ", &useSysFont},
{"FontName = ", &fontName}
});
}
if (!configFound)
ffStrbufSetStatic(&terminalFont->error, "Couldn't find xfce4/xfconf/xfce-perchannel-xml/xfce4-terminal.xml or xfce4/terminal/terminalrc");
if(useSysFont.length == 0 || ffStrbufIgnCaseCompS(&useSysFont, "false") == 0)
{
if(fontName.length == 0)
ffStrbufAppendS(&terminalFont->error, "Couldn't find FontName in .config/xfce4/terminal/terminalrc");
ffStrbufAppendF(&terminalFont->error, "Couldn't find FontName in %s", path);
else
ffFontInitPango(&terminalFont->font, fontName.chars);
}