diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index b7c2d0a5a..68aadea2c 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -69,7 +69,7 @@ static void detectAlacritty(FFTerminalFontResult* terminalFont) { ffFontInitMoveValues(&terminalFont->font, &fontFamily, &fontSize, &fontStyle); } -static void parseGhosttyConfig(const FFstrbuf* path, FFstrbuf* fontName, FFstrbuf* fontNameFallback, FFstrbuf* fontSize, FFlist* configFiles /* list of FFstrbuf */) { +static void parseGhosttyConfig(FFstrbuf* path, FFstrbuf* fontName, FFstrbuf* fontNameFallback, FFstrbuf* fontSize, FFlist* configFiles /* list of FFstrbuf */) { // Maximum number of `config-file` directives to follow, guarding against runaway includes enum { FF_GHOSTTY_MAX_CONFIG_FILES = 16 }; @@ -79,7 +79,18 @@ static void parseGhosttyConfig(const FFstrbuf* path, FFstrbuf* fontName, FFstrbu FF_STRBUF_AUTO_DESTROY temp = ffStrbufCreate(); if (!ffAppendFileBuffer(path->chars, &buffer)) { FF_DEBUG("cannot read config: %s", path->chars); - return; + if (ffStrbufEndsWithS(path, ".ghostty")) { + FF_DEBUG("Trying to load config without .ghostty extension"); + path->chars[path->length - strlen(".ghostty")] = '\0'; + bool ok = ffAppendFileBuffer(path->chars, &buffer); + path->chars[path->length - strlen(".ghostty")] = '.'; + if (!ok) { + FF_DEBUG("cannot read config: %s", path->chars); + return; + } + } else { + return; + } } char* line = nullptr; @@ -394,7 +405,7 @@ static bool detectTerminalFontCommon(const FFTerminalResult* terminal, FFTermina } else if (ffStrbufStartsWithIgnCaseS(&terminal->processName, "contour")) { detectContour(&terminal->exe, terminalFont); } else if (ffStrbufStartsWithIgnCaseS(&terminal->processName, "ghostty")) { - detectGhostty(terminalFont, "com.mitchellh.ghostty/config", "ghostty/config"); + detectGhostty(terminalFont, "com.mitchellh.ghostty/config.ghostty", "ghostty/config.ghostty"); } else if (ffStrbufStartsWithIgnCaseS(&terminal->processName, "Muxy")) { detectGhostty(terminalFont, "Muxy/ghostty.conf", "muxy/ghostty.conf"); } else if (ffStrbufStartsWithIgnCaseS(&terminal->processName, "rio")) {