editorconfig

This commit is contained in:
Linus Dierheimer
2021-03-27 18:14:19 +01:00
parent 46ed1b34cb
commit a1e90ba35c
36 changed files with 88 additions and 78 deletions
+11
View File
@@ -0,0 +1,11 @@
root = true
[*]
end_of_line = lf
indent_style = space
tab_width = 4
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
+1 -1
View File
@@ -178,4 +178,4 @@ __fastfetch_completion()
fi
}
complete -F __fastfetch_completion fastfetch
complete -F __fastfetch_completion fastfetch
+6 -6
View File
@@ -13,7 +13,7 @@ void ffInitState(FFstate* state)
state->passwd = getpwuid(getuid());
uname(&state->utsname);
sysinfo(&state->sysinfo);
ffStrbufInit(&state->terminal.value);
state->terminal.error = NULL;
state->terminal.calculated = false;
@@ -193,7 +193,7 @@ void ffParseFont(char* font, char* buffer)
char name[64];
char size[32];
int scanned = sscanf(font, "%[^,], %[^,]", name, size);
if(scanned == 0)
strcpy(buffer, font);
else if(scanned == 1)
@@ -361,14 +361,14 @@ void ffParseFormatStringV(FFstrbuf* buffer, FFstrbuf* formatstr, uint32_t numArg
ffStrbufAppendS(buffer, "{}");
continue;
}
argIndex = argCounter++;
}
else
{
FFstrbuf argnumstr;
ffStrbufInit(&argnumstr);
while(formatstr->chars[i] != '}' && i < formatstr->length)
ffStrbufAppendC(&argnumstr, formatstr->chars[i++]);
@@ -388,7 +388,7 @@ void ffParseFormatStringV(FFstrbuf* buffer, FFstrbuf* formatstr, uint32_t numArg
ffStrbufDestroy(&argnumstr);
}
if(argIndex == 0)
argIndex = 1;
@@ -444,4 +444,4 @@ void ffPrintFormatString(FFinstance* instance, const char* key, FFstrbuf* format
}
ffStrbufDestroy(&buffer);
}
}
+7 -7
View File
@@ -314,7 +314,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
}
else if(strcasecmp(key, "-r") == 0 || strcasecmp(key, "--recache") == 0)
{
//Set cacheSave as well, beacuse the user expects the values to be cached when expliciting using --recache
//Set cacheSave as well, beacuse the user expects the values to be cached when expliciting using --recache
instance->config.recache = optionParseBoolean(value);
instance->config.cacheSave = instance->config.recache;
}
@@ -400,7 +400,7 @@ static void parseConfigFile(FFinstance* instance, FFdata* data)
strcpy(fileName, xdgConfig);
}
mkdir(fileName, S_IRWXU | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH); //I hope everybody has a config folder but whow knews
strcat(fileName, "/fastfetch/");
mkdir(fileName, S_IRWXU | S_IRGRP | S_IROTH);
@@ -413,7 +413,7 @@ static void parseConfigFile(FFinstance* instance, FFdata* data)
fclose(file);
return;
}
FILE* file = fopen(fileName, "r");
char* lineStart = NULL;
@@ -572,19 +572,19 @@ static void run(FFinstance* instance, FFdata* data)
{
if(data->structure.length == 0)
ffStrbufSetS(&data->structure, FASTFETCH_DEFAULT_STRUCTURE);
char* remaining = data->structure.chars;
char* colon = NULL;
while(true)
{
colon = strchr(remaining, ':');
if(colon != NULL)
*colon = '\0';
parseStructureCommand(instance, data, remaining);
if(colon != NULL)
remaining = colon + 1;
else
+2 -2
View File
@@ -66,7 +66,7 @@ typedef struct FFconfig
FFstrbuf diskFormat;
FFstrbuf batteryFormat;
FFstrbuf localeFormat;
FFstrbuf libPCI;
FFstrbuf libX11;
FFstrbuf libXrandr;
@@ -171,4 +171,4 @@ void ffPrintBattery(FFinstance* instance);
void ffPrintLocale(FFinstance* instance);
void ffPrintColors(FFinstance* instance);
#endif
#endif
+1 -1
View File
@@ -4,4 +4,4 @@
#define FASTFETCH_PROJECT_NAME "@PROJECT_NAME@"
#define FASTFETCH_PROJECT_VERSION "@PROJECT_VERSION@"
#endif // FASTFETCH_INDLUDED_fastfetch_config_h_in
#endif // FASTFETCH_INDLUDED_fastfetch_config_h_in
+2 -2
View File
@@ -9,7 +9,7 @@ int main(int argc, char** argv)
//Configuration
ffLoadLogoSet(&instance.config, "arch");
ffStrbufSetS(&instance.config.color, instance.config.logo.color); //Use the primary color of the logo as key color
//Printing
ffPrintTitle(&instance);
ffPrintSeperator(&instance);
@@ -38,4 +38,4 @@ int main(int argc, char** argv)
ffFinish(&instance);
return 0;
}
}
+3 -3
View File
@@ -38,7 +38,7 @@ static void printBattery(FFinstance* instance, uint8_t index)
manufactor.length == 0 &&
model.length == 0 &&
technology.length == 0 &&
capacity.length == 0 &&
capacity.length == 0 &&
status.length == 0
) {
ffPrintError(instance, key, "No file in /sys/class/power_supply/BAT0/ could be read or all battery options are disabled");
@@ -59,7 +59,7 @@ static void printBattery(FFinstance* instance, uint8_t index)
if(capacity.length > 0)
{
printf("[%s%%", capacity.chars);
if(status.length == 0)
puts("]");
else
@@ -105,4 +105,4 @@ void ffPrintBattery(FFinstance* instance)
closedir(dir);
}
}
}
}
+1 -1
View File
@@ -4,4 +4,4 @@ void ffPrintBreak(FFinstance* instance)
{
ffPrintLogoLine(instance);
putchar('\n');
}
}
+1 -1
View File
@@ -15,4 +15,4 @@ void ffPrintColors(FFinstance* instance)
printf("\033[48;5;%dm ", i);
puts("\033[0m");
}
}
+4 -4
View File
@@ -12,7 +12,7 @@ void ffPrintCPU(FFinstance* instance)
ffPrintError(instance, "CPU", "\"model name%*s %[^\\n]\" not found in \"/proc/cpuinfo\"");
return;
}
FILE* frequencyFile = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq", "r");
if(frequencyFile == NULL)
{
@@ -40,14 +40,14 @@ void ffPrintCPU(FFinstance* instance)
ffStrbufSetF(&cpu, "%s (%i) @ %.9gGHz", name, numProcs, ghz);
}
else
{
{
ffParseFormatString(&cpu, &instance->config.cpuFormat, 3,
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, name},
(FFformatarg){FF_FORMAT_ARG_TYPE_INT, &numProcs},
(FFformatarg){FF_FORMAT_ARG_TYPE_DOUBLE, &ghz}
);
}
ffPrintAndSaveCachedValue(instance, "CPU", &cpu);
ffStrbufDestroy(&cpu);
}
}
+1 -1
View File
@@ -4,4 +4,4 @@ void ffPrintCustom(FFinstance* instance, const char* key, const char* value)
{
ffPrintLogoAndKey(instance, key);
puts(value);
}
}
+1 -1
View File
@@ -78,4 +78,4 @@ void ffPrintDesktopEnvironment(FFinstance* instance)
ffStrbufDestroy(&sessionType);
ffStrbufDestroy(&sessionVersion);
ffStrbufDestroy(&sessionDesktop);
}
}
+1 -1
View File
@@ -32,4 +32,4 @@ void ffPrintDisk(FFinstance* instance)
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT8, &percentage}
);
}
}
}
+5 -5
View File
@@ -4,7 +4,7 @@ void ffPrintFont(FFinstance* instance)
{
char plasma[256];
ffParsePropFileHome(instance, ".config/kdeglobals", "font=%[^\n]", plasma);
char plasmaPretty[256];
if(plasma[0] == '\0')
strcpy(plasmaPretty, "Noto Sans (10pt)");
@@ -13,7 +13,7 @@ void ffPrintFont(FFinstance* instance)
char gtk2[256];
ffParsePropFileHome(instance, ".gtkrc-2.0", "gtk-font-name=\"%[^\"]+", gtk2);
char gtk2Pretty[256];
if(gtk2[0] == '\0')
gtk2Pretty[0] = '\0';
@@ -22,7 +22,7 @@ void ffPrintFont(FFinstance* instance)
char gtk3[256];
ffParsePropFileHome(instance, ".config/gtk-3.0/settings.ini", "gtk-font-name=%[^\n]", gtk3);
char gtk3Pretty[256];
if(gtk3[0] == '\0')
gtk3Pretty[0] = '\0';
@@ -37,7 +37,7 @@ void ffPrintFont(FFinstance* instance)
gtk4Pretty[0] = '\0';
else
ffParseFont(gtk4, gtk4Pretty);
FF_STRBUF_CREATE(gtkPretty);
ffFormatGtkPretty(&gtkPretty, gtk2Pretty, gtk3Pretty, gtk4Pretty);
@@ -59,4 +59,4 @@ void ffPrintFont(FFinstance* instance)
}
ffStrbufDestroy(&gtkPretty);
}
}
+3 -3
View File
@@ -4,7 +4,7 @@
#include <dlfcn.h>
static void handleGPU(FFinstance* instance, struct pci_access* pacc, struct pci_dev* dev, uint16_t counter, char*(*ffpci_lookup_name)(struct pci_access*, char*, int, int, ...))
{
{
char key[8];
sprintf(key, "GPU%hu", counter);
@@ -31,7 +31,7 @@ static void handleGPU(FFinstance* instance, struct pci_access* pacc, struct pci_
}
else
{
ffParseFormatString(&gpu, &instance->config.gpuFormat, 2,
ffParseFormatString(&gpu, &instance->config.gpuFormat, 2,
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, vendorPretty},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, name}
);
@@ -120,4 +120,4 @@ void ffPrintGPU(FFinstance* instance)
ffpci_cleanup(pacc);
dlclose(pci);
}
}
+2 -2
View File
@@ -10,7 +10,7 @@ void ffPrintHost(FFinstance* instance)
FF_STRBUF_CREATE(name);
ffGetFileContent("/sys/devices/virtual/dmi/id/product_name", &name);
FF_STRBUF_CREATE(version);
ffGetFileContent("/sys/devices/virtual/dmi/id/product_version", &version);
@@ -62,4 +62,4 @@ void ffPrintHost(FFinstance* instance)
ffStrbufDestroy(&family);
ffStrbufDestroy(&name);
ffStrbufDestroy(&version);
}
}
+3 -3
View File
@@ -4,7 +4,7 @@ void ffPrintIcons(FFinstance* instance)
{
char plasma[256];
ffParsePropFileHome(instance, ".config/kdeglobals", "Theme=%[^\n]", plasma);
char gtk2[256];
ffParsePropFileHome(instance, ".gtkrc-2.0", "gtk-icon-theme-name=\"%[^\"]+", gtk2);
if(gtk2[0] == '\0')
@@ -26,7 +26,7 @@ void ffPrintIcons(FFinstance* instance)
if(instance->config.iconsFormat.length == 0)
{
ffPrintLogoAndKey(instance, "Icons");
if(plasma[0] == '\0')
printf("Breeze [Plasma], ");
else
@@ -46,4 +46,4 @@ void ffPrintIcons(FFinstance* instance)
}
ffStrbufDestroy(&gtkPretty);
}
}
+1 -1
View File
@@ -15,4 +15,4 @@ void ffPrintKernel(FFinstance* instance)
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.version}
);
}
}
}
-1
View File
@@ -52,7 +52,6 @@ void ffPrintLocale(FFinstance* instance)
);
}
ffPrintAndSaveCachedValue(instance, "Locale", &locale);
ffStrbufDestroy(&locale);
}
+1 -1
View File
@@ -43,4 +43,4 @@ void ffPrintMemory(FFinstance* instance)
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT8, &percentage}
);
}
}
}
+3 -3
View File
@@ -52,7 +52,7 @@ void ffPrintOS(FFinstance* instance)
}
fclose(osRelease);
if(line != NULL)
free(line);
@@ -71,7 +71,7 @@ void ffPrintOS(FFinstance* instance)
else
{
if(name[0] != '\0')
ffStrbufAppendS(&os, name);
ffStrbufAppendS(&os, name);
else
ffStrbufAppendS(&os, id);
@@ -126,4 +126,4 @@ void ffPrintOS(FFinstance* instance)
ffPrintAndSaveCachedValue(instance, "OS", &os);
ffStrbufDestroy(&os);
}
}
+4 -4
View File
@@ -15,7 +15,7 @@ static uint32_t get_num_dirs(const char* dirname) {
if(entry->d_type == DT_DIR)
++num_dirs;
}
num_dirs -= 2; // accounting for . and ..
closedir(dirp);
@@ -60,7 +60,7 @@ void ffPrintPackages(FFinstance* instance)
ffPrintFormatString(instance, "Packages", &instance->config.packagesFormat, 3,
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &all},
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &pacman},
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &flatpak}
);
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &flatpak}
);
}
}
}
+1 -1
View File
@@ -94,4 +94,4 @@ void ffPrintResolution(FFinstance* instance)
ffPrintAndSaveCachedValue(instance, "Resolution", &resolution);
ffStrbufDestroy(&resolution);
}
}
+1 -1
View File
@@ -7,4 +7,4 @@ void ffPrintSeperator(FFinstance* instance)
for(uint8_t i = 0; i < instance->config.titleLength; i++)
putchar('-');
putchar('\n');
}
}
+1 -1
View File
@@ -43,4 +43,4 @@ void ffPrintShell(FFinstance* instance)
ffPrintAndSaveCachedValue(instance, "Shell", &shell);
ffStrbufDestroy(&shell);
}
}
+2 -2
View File
@@ -36,7 +36,7 @@ static void getTerminalName(FFinstance* instance, const char* pid, char* termina
getTerminalName(instance, ppid, terminal, error);
return;
}
if(
strcasecmp(name, "systemd") == 0 ||
strcasecmp(name, "init") == 0 ||
@@ -85,7 +85,7 @@ void ffPrintTerminal(FFinstance* instance)
ffPrintError(instance, "Terminal", instance->state.terminal.error);
return;
}
if(instance->config.terminalFormat.length == 0)
{
ffPrintLogoAndKey(instance, "Terminal");
+3 -3
View File
@@ -48,14 +48,14 @@ static void printTTY(FFinstance* instance)
ffParsePropFile("/etc/vconsole.conf", "Font=%[^\n]", font);
if(font[0] == '\0')
strcpy(font, "hardware-supplied VGA font");
printTerminalFont(instance, font);
}
void ffPrintTerminalFont(FFinstance* instance)
{
ffPopulateTerminal(instance);
if(instance->state.terminal.error != NULL)
{
ffPrintError(instance, "Terminal Font", "Terminal Font needs successfull terminal detection");
@@ -68,4 +68,4 @@ void ffPrintTerminalFont(FFinstance* instance)
printTTY(instance);
else
ffPrintError(instance, "Terminal Font", "Unknown terminal: %s", instance->state.terminal.value);
}
}
+2 -2
View File
@@ -4,7 +4,7 @@ void ffPrintTheme(FFinstance* instance)
{
char plasma[256];
ffParsePropFileHome(instance, ".config/kdeglobals", "Name=%[^\n]", plasma);
char gtk2[256];
ffParsePropFileHome(instance, ".gtkrc-2.0", "gtk-theme-name=\"%[^\"]+", gtk2);
if(gtk2[0] == '\0')
@@ -42,4 +42,4 @@ void ffPrintTheme(FFinstance* instance)
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &gtkPretty}
);
}
}
}
+1 -1
View File
@@ -12,4 +12,4 @@ void ffPrintTitle(FFinstance* instance)
printf(FASTFETCH_TEXT_MODIFIER_BOLT"%s%s"FASTFETCH_TEXT_MODIFIER_RESET"@"FASTFETCH_TEXT_MODIFIER_BOLT"%s%s"FASTFETCH_TEXT_MODIFIER_RESET"\n",
instance->config.color.chars, instance->state.passwd->pw_name, instance->config.color.chars, hostname
);
}
}
+2 -2
View File
@@ -3,7 +3,7 @@
void ffPrintUptime(FFinstance* instance)
{
uint32_t days = instance->state.sysinfo.uptime / 86400;
uint32_t hours = (instance->state.sysinfo.uptime - (days * 86400)) / 3600;
uint32_t hours = (instance->state.sysinfo.uptime - (days * 86400)) / 3600;
uint32_t minutes = (instance->state.sysinfo.uptime - (days * 86400) - (hours * 3600)) / 60;
uint32_t seconds = instance->state.sysinfo.uptime - (days * 86400) - (hours * 3600) - (minutes * 60);
@@ -35,4 +35,4 @@ void ffPrintUptime(FFinstance* instance)
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &seconds}
);
}
}
}
+2 -2
View File
@@ -9,7 +9,7 @@ static bool parseProcessName(FFstrbuf* name)
else
return false;
return true;
return true;
}
void ffPrintWM(FFinstance* instance)
@@ -62,4 +62,4 @@ void ffPrintWM(FFinstance* instance)
}
ffStrbufDestroy(&name);
}
}
+5 -5
View File
@@ -40,7 +40,7 @@ void ffStrbufInitA(FFstrbuf* strbuf, uint32_t allocate)
strbuf->allocated = allocate;
strbuf->chars = (char*) malloc(sizeof(char) * strbuf->allocated);
ffStrbufClear(strbuf);
}
@@ -168,7 +168,7 @@ void ffStrbufAppendNS(FFstrbuf* strbuf, uint32_t length, const char* value)
{
if(value[i] == '\0')
break;
strbuf->chars[strbuf->length++] = value[i];
}
strbuf->chars[strbuf->length] = '\0';
@@ -204,7 +204,7 @@ void ffStrbufAppendVF(FFstrbuf* strbuf, const char* format, va_list arguments)
int written = vsnprintf(strbuf->chars + strbuf->length, strbuf->allocated - strbuf->length, format, localArguments);
va_end(localArguments);
if(strbuf->length + written >= strbuf->allocated)
{
ffStrbufEnsureCapacity(strbuf, strbuf->allocated * 2);
@@ -283,7 +283,7 @@ void ffStrbufTrimLeft(FFstrbuf* strbuf, char c)
}
void ffStrbufTrimRight(FFstrbuf* strbuf, char c)
{
{
while(strbuf->length > 0 && strbuf->chars[strbuf->length - 1] == c)
--strbuf->length;
@@ -302,4 +302,4 @@ void ffStrbufDestroy(FFstrbuf* strbuf)
strbuf->allocated = 0;
strbuf->chars = NULL;
strbuf->length = 0;
}
}
+1 -1
View File
@@ -53,4 +53,4 @@ bool ffValuestoreContains(FFvaluestore* vs, const char* name)
void ffValuestoreDelete(FFvaluestore* vs)
{
free(vs->pairs);
}
}
+1 -1
View File
@@ -24,4 +24,4 @@ const char* ffValuestoreGet(FFvaluestore* vs, const char* name);
bool ffValuestoreContains(FFvaluestore* vs, const char* name);
void ffValuestoreDelete(FFvaluestore* vs);
#endif
#endif
+2 -2
View File
@@ -17,7 +17,7 @@
int main(int argc, char** argv)
{
FFinstance instance;
FASTFETCH_TEST_PERFORMANCE(
puts("Initialization");
ffInitState(&instance.state);
@@ -56,4 +56,4 @@ int main(int argc, char** argv)
FASTFETCH_TEST_PERFORMANCE(ffPrintColors(&instance))
return 0;
}
}