@@ -158,32 +158,51 @@ static void logoPrintFile(FFinstance* instance, bool doColorReplacement)
158158
159159static void logoPrintDetected (FFinstance * instance )
160160{
161- if (instance -> config .logoSource .length > 0 )
162- {
163- if (
164- !ffLogoPrintBuiltinIfExists (instance ) &&
165- !ffLogoPrintImageIfExists (instance , FF_LOGO_TYPE_KITTY ) &&
166- !ffLogoPrintImageIfExists (instance , FF_LOGO_TYPE_CHAFA )
167- ) logoPrintFile (instance , true);
161+ //If no logo source is given, detect the logo from OS and print the right builtin one
162+ if (instance -> config .logoSource .length == 0 )
163+ ffLogoPrintBuiltinDetected (instance );
164+
165+ //If a logo source is given, first look if it is the name of a builtin logo
166+ if (ffLogoPrintBuiltinIfExists (instance ))
168167 return ;
168+
169+ const FFTerminalShellResult * terminalShell = ffDetectTerminalShell (instance );
170+
171+ FFLogoImageResult imageResult = FF_LOGO_IMAGE_RESULT_INIT_ERROR ;
172+
173+ //Terminals that are known to support kitty graphics protocol
174+ //Try to load the logo as image.
175+ if (
176+ ffStrbufIgnCaseCompS (& terminalShell -> terminalProcessName , "kitty" ) == 0 ||
177+ ffStrbufIgnCaseCompS (& terminalShell -> terminalProcessName , "konsole" ) == 0 ||
178+ ffStrbufIgnCaseCompS (& terminalShell -> terminalProcessName , "wezterm" ) == 0 ||
179+ ffStrbufIgnCaseCompS (& terminalShell -> terminalProcessName , "wayst" ) == 0
180+ ) {
181+ imageResult = ffLogoPrintImageIfExists (instance , FF_LOGO_TYPE_KITTY );
182+ if (imageResult == FF_LOGO_IMAGE_RESULT_SUCCESS )
183+ return ;
169184 }
170185
171- ffLogoPrintBuiltinDetected (instance );
186+ //If the logo can be loaded as an image, convert it to ascii art.
187+ //This happens in all terminals, that don't support kitty graphics protocol
188+ if (
189+ imageResult != FF_LOGO_IMAGE_RESULT_RUN_ERROR &&
190+ ffLogoPrintImageIfExists (instance , FF_LOGO_TYPE_CHAFA ) == FF_LOGO_IMAGE_RESULT_SUCCESS
191+ ) return ;
192+
193+ //Print the content of the file as logo
194+ logoPrintFile (instance , true);
172195}
173196
174197void ffPrintLogo (FFinstance * instance )
175198{
176199 if (instance -> config .mainColor .length == 0 )
177200 ffLogoSetMainColor (instance );
178201
179- if (( //Logo type needs set logo name, but nothing was given. Print question mark
180- instance -> config .logoType == FF_LOGO_TYPE_BUILTIN ||
181- instance -> config .logoType == FF_LOGO_TYPE_FILE ||
182- instance -> config .logoType == FF_LOGO_TYPE_RAW ||
183- instance -> config .logoType == FF_LOGO_TYPE_SIXEL ||
184- instance -> config .logoType == FF_LOGO_TYPE_KITTY ||
185- instance -> config .logoType == FF_LOGO_TYPE_CHAFA
186- ) && instance -> config .logoSource .length == 0 )
202+ if ( //Logo type needs set logo name, but nothing was given. Print question mark
203+ instance -> config .logoType != FF_LOGO_TYPE_AUTO &&
204+ instance -> config .logoSource .length == 0
205+ )
187206 ffLogoPrintUnknown (instance );
188207 else if (instance -> config .logoType == FF_LOGO_TYPE_BUILTIN )
189208 {
@@ -196,7 +215,7 @@ void ffPrintLogo(FFinstance* instance)
196215 logoPrintFile (instance , false);
197216 else if (instance -> config .logoType == FF_LOGO_TYPE_SIXEL || instance -> config .logoType == FF_LOGO_TYPE_KITTY || instance -> config .logoType == FF_LOGO_TYPE_CHAFA )
198217 {
199- if (! ffLogoPrintImageIfExists (instance , instance -> config .logoType ))
218+ if (ffLogoPrintImageIfExists (instance , instance -> config .logoType ) != FF_LOGO_IMAGE_RESULT_SUCCESS )
200219 ffLogoPrintBuiltinDetected (instance );
201220 }
202221 else
0 commit comments