2021-04-03 23:10:14 +02:00
#include "fastfetch.h"
2021-04-15 18:59:26 +02:00
#define FF_WMTHEME_MODULE_NAME "WM Theme"
#define FF_WMTHEME_NUM_FORMAT_ARGS 1
2021-04-03 23:10:14 +02:00
static void printWMTheme ( FFinstance * instance , const char * theme )
{
if ( instance -> config . wmThemeFormat . length == 0 )
{
2021-04-15 18:59:26 +02:00
ffPrintLogoAndKey ( instance , FF_WMTHEME_MODULE_NAME , 0 , & instance -> config . wmThemeKey );
2021-04-03 23:10:14 +02:00
puts ( theme );
}
else
{
2021-04-15 18:59:26 +02:00
ffPrintFormatString ( instance , FF_WMTHEME_MODULE_NAME , 0 , & instance -> config . wmThemeKey , & instance -> config . wmThemeFormat , NULL , FF_WMTHEME_NUM_FORMAT_ARGS , ( FFformatarg []){
{ FF_FORMAT_ARG_TYPE_STRING , theme }
});
2021-04-03 23:10:14 +02:00
}
}
static void printKWin ( FFinstance * instance )
{
char theme [ 256 ];
theme [ 0 ] = '\0' ;
ffParsePropFileHome ( instance , ".config/kwinrc" , "theme=%s" , theme );
if ( theme [ 0 ] == '\0' )
{
2021-04-15 18:59:26 +02:00
ffPrintError ( instance , FF_WMTHEME_MODULE_NAME , 0 , & instance -> config . wmThemeKey , & instance -> config . wmThemeFormat , FF_WMTHEME_NUM_FORMAT_ARGS , "Couldn't find \" theme= \" in \" .config/kwinrc \" " );
2021-04-03 23:10:14 +02:00
return ;
}
printWMTheme ( instance , theme );
}
void ffPrintWMTheme ( FFinstance * instance )
{
2021-04-22 21:41:42 +02:00
const FFWMResult * result = ffCalculateWM ( instance );
2021-04-03 23:10:14 +02:00
2021-04-22 21:41:42 +02:00
if ( result -> prettyName . length == 0 )
2021-04-03 23:10:14 +02:00
{
2021-04-15 18:59:26 +02:00
ffPrintError ( instance , FF_WMTHEME_MODULE_NAME , 0 , & instance -> config . wmThemeKey , & instance -> config . wmThemeFormat , FF_WMTHEME_NUM_FORMAT_ARGS , "WM Theme needs sucessfull WM detection" );
2021-04-03 23:10:14 +02:00
return ;
}
2021-04-22 21:41:42 +02:00
if ( ffStrbufIgnCaseCompS ( & result -> prettyName , "KWin" ) == 0 )
2021-04-03 23:10:14 +02:00
printKWin ( instance );
else
2021-04-22 21:41:42 +02:00
ffPrintError ( instance , FF_WMTHEME_MODULE_NAME , 0 , & instance -> config . wmThemeKey , & instance -> config . wmThemeFormat , FF_WMTHEME_NUM_FORMAT_ARGS , "Unknown WM: %s" , result -> prettyName . chars );
2021-04-03 23:10:14 +02:00
}