diff --git a/src/battery.c b/src/battery.c index c39b622aa..c273562e3 100644 --- a/src/battery.c +++ b/src/battery.c @@ -7,16 +7,14 @@ void ffPrintBattery(FFstate* state) FILE* fullFile = fopen("/sys/class/power_supply/BAT0/charge_full", "r"); if(fullFile == NULL) { - if(state->showErrors) - ffPrintError(state, "Battery", "fopen(\"/sys/class/power_supply/BAT0/charge_full\", \"r\") == NULL"); + ffPrintError(state, "Battery", "fopen(\"/sys/class/power_supply/BAT0/charge_full\", \"r\") == NULL"); return; } uint32_t full; scanned = fscanf(fullFile, "%u", &full); if(scanned != 1) { - if(state->showErrors) - ffPrintError(state, "Battery", "fscanf(fullFile, \"%u\", &full) != 1"); + ffPrintError(state, "Battery", "fscanf(fullFile, \"%u\", &full) != 1"); return; } fclose(fullFile); @@ -24,16 +22,14 @@ void ffPrintBattery(FFstate* state) FILE* nowFile = fopen("/sys/class/power_supply/BAT0/charge_now", "r"); if(nowFile == NULL) { - if(state->showErrors) - ffPrintError(state, "Battery", "fopen(\"/sys/class/power_supply/BAT0/charge_now\", \"r\") == NULL"); + ffPrintError(state, "Battery", "fopen(\"/sys/class/power_supply/BAT0/charge_now\", \"r\") == NULL"); return; } uint32_t now; scanned = fscanf(nowFile, "%u", &now); if(scanned != 1) { - if(state->showErrors) - ffPrintError(state, "Battery", "fscanf(nowFile, \"%u\", &now) != 1"); + ffPrintError(state, "Battery", "fscanf(nowFile, \"%u\", &now) != 1"); return; } fclose(nowFile); @@ -41,16 +37,14 @@ void ffPrintBattery(FFstate* state) FILE* statusFile = fopen("/sys/class/power_supply/BAT0/status", "r"); if(statusFile == NULL) { - if(state->showErrors) - ffPrintError(state, "Battery", "fopen(\"/sys/class/power_supply/BAT0/status\", \"r\") == NULL"); + ffPrintError(state, "Battery", "fopen(\"/sys/class/power_supply/BAT0/status\", \"r\") == NULL"); return; } char status[256]; scanned = fscanf(statusFile, "%s", status); if(scanned != 1) { - if(state->showErrors) - ffPrintError(state, "Battery", "fscanf(statusFile, \"%u\", &status) != 1"); + ffPrintError(state, "Battery", "fscanf(statusFile, \"%u\", &status) != 1"); return; } fclose(statusFile); diff --git a/src/cpu.c b/src/cpu.c index b73b40e86..44e410900 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -8,24 +8,21 @@ void ffPrintCPU(FFstate* state) ffParsePropFile("/proc/cpuinfo", "model name%*s %[^\n]", name); if(name[0] == '\0') { - if(state->showErrors) - ffPrintError(state, "CPU", "\"model name%*s %[^\\n]\" not found in \"/proc/cpuinfo\""); + ffPrintError(state, "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) { - if(state->showErrors) - ffPrintError(state, "CPU", "fopen(\"/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq\", \"r\") == NULL"); + ffPrintError(state, "CPU", "fopen(\"/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq\", \"r\") == NULL"); return; } uint32_t frequency; int scanned = fscanf(frequencyFile, "%u", &frequency); if(scanned != 1) { - if(state->showErrors) - ffPrintError(state, "CPU", "fscanf(frequencyFile, \"%s\", frequency) != 1"); + ffPrintError(state, "CPU", "fscanf(frequencyFile, \"%s\", frequency) != 1"); return; } fclose(frequencyFile); diff --git a/src/desktopenvironment.c b/src/desktopenvironment.c index d1099f9fe..335813595 100644 --- a/src/desktopenvironment.c +++ b/src/desktopenvironment.c @@ -21,8 +21,7 @@ void ffPrintDesktopEnvironment(FFstate* state) const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP"); if(currentDesktop == NULL) { - if(state->showErrors) - ffPrintError(state, "DE", "getenv(\"XDG_CURRENT_DESKTOP\") == NULL"); + ffPrintError(state, "DE", "getenv(\"XDG_CURRENT_DESKTOP\") == NULL"); return; } diff --git a/src/disk.c b/src/disk.c index 55c33282f..ea1c27db6 100644 --- a/src/disk.c +++ b/src/disk.c @@ -8,8 +8,7 @@ void ffPrintDisk(FFstate* state) int ret = statvfs("/", &fs); if(ret != 0) { - if(state->showErrors) - ffPrintError(state, "Disk (/)", "statvfs(\"/\", &fs) != 0"); + ffPrintError(state, "Disk (/)", "statvfs(\"/\", &fs) != 0"); return; } diff --git a/src/fastfetch.c b/src/fastfetch.c index 8954930cf..eed8bc7b7 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -92,6 +92,9 @@ void ffPrintGtkPretty(const char* gtk2, const char* gtk3, const char* gtk4) void ffPrintError(FFstate* state, const char* key, const char* message) { + if(!state->showErrors) + return; + ffPrintLogoAndKey(state, key); printf(FASTFETCH_TEXT_MODIFIER_ERROR"%s\n"FASTFETCH_TEXT_MODIFIER_RESET, message); } diff --git a/src/host.c b/src/host.c index c778ca5eb..3880cdd0f 100644 --- a/src/host.c +++ b/src/host.c @@ -5,15 +5,13 @@ void ffPrintHost(FFstate* state) FILE* nameFile = fopen("/sys/devices/virtual/dmi/id/product_name", "r"); if(nameFile == NULL) { - if(state->showErrors) - ffPrintError(state, "Host", "fopen(\"/sys/devices/virtual/dmi/id/product_name\", \"r\") == NULL"); + ffPrintError(state, "Host", "fopen(\"/sys/devices/virtual/dmi/id/product_name\", \"r\") == NULL"); return; } char name[256]; if(fscanf(nameFile, "%[^\n]", name) != 1) { - if(state->showErrors) - ffPrintError(state, "Host", "fscanf(nameFile, \"%[^\\n]\", name) != 1"); + ffPrintError(state, "Host", "fscanf(nameFile, \"%[^\\n]\", name) != 1"); return; } fclose(nameFile); diff --git a/src/locale.c b/src/locale.c index 3a5f809c1..057d411db 100644 --- a/src/locale.c +++ b/src/locale.c @@ -6,8 +6,7 @@ void ffPrintLocale(FFstate* state) ffParsePropFile("/etc/locale.conf", "LANG=%[^\n]", locale); if(locale[0] == '\0') { - if(state->showErrors) - ffPrintError(state, "Locale", "\"LANG=%[^\\n]\" not found in \"/etc/locale.conf\""); + ffPrintError(state, "Locale", "\"LANG=%[^\\n]\" not found in \"/etc/locale.conf\""); return; } diff --git a/src/memory.c b/src/memory.c index db88958ba..eb8f8b36e 100644 --- a/src/memory.c +++ b/src/memory.c @@ -5,8 +5,7 @@ void ffPrintMemory(FFstate* state) { FILE* meminfo = fopen("/proc/meminfo", "r"); if(meminfo == NULL) { - if(state->showErrors) - ffPrintError(state, "Memory", "fopen(\"/proc/meminfo\", \"r\") == NULL"); + ffPrintError(state, "Memory", "fopen(\"/proc/meminfo\", \"r\") == NULL"); return; } diff --git a/src/os.c b/src/os.c index 9d76c7741..56e6e8934 100644 --- a/src/os.c +++ b/src/os.c @@ -6,8 +6,7 @@ void ffPrintOS(FFstate* state) ffParsePropFile("/etc/os-release", "NAME=\"%[^\"]+", name); if(name[0] == '\0') { - if(state->showErrors) - ffPrintError(state, "OS", "\"NAME=\\\"%[^\\\"]+\" not found in \"/etc/os-release\""); + ffPrintError(state, "OS", "\"NAME=\\\"%[^\\\"]+\" not found in \"/etc/os-release\""); return; } diff --git a/src/shell.c b/src/shell.c index 31bd66492..43308e71f 100644 --- a/src/shell.c +++ b/src/shell.c @@ -7,8 +7,7 @@ void ffPrintShell(FFstate* state) char* shellPath = getenv("SHELL"); if(shellPath == NULL) { - if(state->showErrors) - ffPrintError(state, "Shell", "getenv(\"SHELL\") == NULL"); + ffPrintError(state, "Shell", "getenv(\"SHELL\") == NULL"); return; } diff --git a/src/terminal.c b/src/terminal.c index 6675ae54a..3677cc80e 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -10,12 +10,9 @@ void printTerminalName(FFstate* state, const char* pid) FILE* stat = fopen(file, "r"); if(stat == NULL) { - if(state->showErrors) - { - char error[256]; - sprintf(error, "fopen(\"%s\", \"r\") == NULL", file); - ffPrintError(state, "Terminal", error); - } + char error[256]; + sprintf(error, "fopen(\"%s\", \"r\") == NULL", file); + ffPrintError(state, "Terminal", error); return; } @@ -23,8 +20,7 @@ void printTerminalName(FFstate* state, const char* pid) char ppid[256]; if(fscanf(stat, "%*s (%[^)])%*s%s", name, ppid) != 2) { - if(state->showErrors) - ffPrintError(state, "Terminal", "fscanf(stat, \"%*s (%[^)])%*s%s\", name, ppid) != 2"); + ffPrintError(state, "Terminal", "fscanf(stat, \"%*s (%[^)])%*s%s\", name, ppid) != 2"); return; }