all keys can now be set!

This commit is contained in:
Linus Dierheimer
2021-04-03 11:39:59 +02:00
parent a8821cf6f0
commit 08066a76f0
26 changed files with 644 additions and 344 deletions
+45 -11
View File
@@ -6,31 +6,42 @@ static void printBattery(FFinstance* instance, uint8_t index)
{
FF_STRBUF_CREATE(manufactor);
char manufactorPath[42];
sprintf(manufactorPath, "/sys/class/power_supply/BAT%i/manufacturer", index);
sprintf(manufactorPath, "/sys/class/power_supply/BAT%hhu/manufacturer", index);
ffGetFileContent(manufactorPath, &manufactor);
FF_STRBUF_CREATE(model);
char modelPath[40];
sprintf(modelPath, "/sys/class/power_supply/BAT%i/model_name", index);
sprintf(modelPath, "/sys/class/power_supply/BAT%hhu/model_name", index);
ffGetFileContent(modelPath, &model);
FF_STRBUF_CREATE(technology);
char technologyPath[40];
sprintf(technologyPath, "/sys/class/power_supply/BAT%i/technology", index);
sprintf(technologyPath, "/sys/class/power_supply/BAT%hhu/technology", index);
ffGetFileContent(technologyPath, &technology);
FF_STRBUF_CREATE(capacity);
char capacityPath[38];
sprintf(capacityPath, "/sys/class/power_supply/BAT%i/capacity", index);
sprintf(capacityPath, "/sys/class/power_supply/BAT%hhu/capacity", index);
ffGetFileContent(capacityPath, &capacity);
FF_STRBUF_CREATE(status);
char statusPath[36];
sprintf(statusPath, "/sys/class/power_supply/BAT%i/status", index);
sprintf(statusPath, "/sys/class/power_supply/BAT%hhu/status", index);
ffGetFileContent(statusPath, &status);
char key[10];
sprintf(key, "Battery %i", index);
uint8_t indexPlusOne = index + 1;
FF_STRBUF_CREATE(key);
if(instance->config.batteryKey.length == 0)
{
ffStrbufAppendF(&key, "Battery %hhu", indexPlusOne);
}
else
{
ffParseFormatString(&key, &instance->config.batteryKey, 1,
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT8, &indexPlusOne}
);
}
if(instance->config.batteryFormat.length == 0)
{
@@ -41,11 +52,11 @@ static void printBattery(FFinstance* instance, uint8_t index)
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");
ffPrintError(instance, &key, NULL, "No file in /sys/class/power_supply/BAT%hhu/ could be read or all battery options are disabled", index);
return;
}
ffPrintLogoAndKey(instance, key);
ffPrintLogoAndKey(instance, &key, NULL);
if(manufactor.length > 0)
printf("%s ", manufactor.chars);
@@ -75,7 +86,7 @@ static void printBattery(FFinstance* instance, uint8_t index)
}
else
{
ffPrintFormatString(instance, key, &instance->config.batteryFormat, 5,
ffPrintFormatString(instance, &key, NULL, &instance->config.batteryFormat, 5,
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &manufactor},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &model},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &technology},
@@ -89,10 +100,12 @@ static void printBattery(FFinstance* instance, uint8_t index)
ffStrbufDestroy(&technology);
ffStrbufDestroy(&capacity);
ffStrbufDestroy(&status);
ffStrbufDestroy(&key);
}
void ffPrintBattery(FFinstance* instance)
{
uint8_t batteryCounter = 0;
for(uint8_t i = 0; i < 5; i++)
{
char path[30];
@@ -101,8 +114,29 @@ void ffPrintBattery(FFinstance* instance)
DIR* dir = opendir(path);
if(dir != NULL)
{
printBattery(instance, i);
printBattery(instance, batteryCounter++);
closedir(dir);
}
}
if(batteryCounter == 0)
{
if(!instance->config.showErrors)
return;
FF_STRBUF_CREATE(key);
if(instance->config.batteryKey.length == 0)
{
ffStrbufSetS(&key, "Battery");
}
else
{
ffParseFormatString(&key, &instance->config.batteryKey, 1,
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT8, &batteryCounter}
);
}
ffPrintError(instance, &key, NULL, "No battery found in /sys/class/power_supply/");
ffStrbufDestroy(&key);
}
}
+3 -3
View File
@@ -20,7 +20,7 @@ static double getGhz(const char* file)
void ffPrintCPU(FFinstance* instance)
{
if(ffPrintCachedValue(instance, "CPU"))
if(ffPrintCachedValue(instance, &instance->config.cpuKey, "CPU"))
return;
char name[256]; name[0] = '\0';
@@ -100,7 +100,7 @@ void ffPrintCPU(FFinstance* instance)
ffStrbufAppendS(&cpu, " unknwon processor");
else
{
ffPrintError(instance, "CPU", "No CPU info found in /proc/cpuinfo");
ffPrintError(instance, &instance->config.cpuKey, "CPU", "No CPU info found in /proc/cpuinfo");
ffStrbufDestroy(&cpu);
ffStrbufDestroy(&namePretty);
return;
@@ -129,7 +129,7 @@ void ffPrintCPU(FFinstance* instance)
);
}
ffPrintAndSaveCachedValue(instance, "CPU", &cpu);
ffPrintAndSaveCachedValue(instance, &instance->config.cpuKey, "CPU", &cpu);
ffStrbufDestroy(&cpu);
ffStrbufDestroy(&namePretty);
+1 -1
View File
@@ -2,6 +2,6 @@
void ffPrintCustom(FFinstance* instance, const char* key, const char* value)
{
ffPrintLogoAndKey(instance, key);
ffPrintLogoAndKey(instance, NULL, key);
puts(value);
}
+3 -3
View File
@@ -42,11 +42,11 @@ void ffPrintDesktopEnvironment(FFinstance* instance)
{
if(sessionDesktop.length == 0 && sessionType.length == 0)
{
ffPrintError(instance, "DE", "Neither DE nor Display Server could be determined");
ffPrintError(instance, &instance->config.deKey, "DE", "Neither DE nor Display Server could be determined");
return;
}
ffPrintLogoAndKey(instance, "DE");
ffPrintLogoAndKey(instance, &instance->config.deKey, "DE");
if(sessionDesktop.length > 0)
{
@@ -69,7 +69,7 @@ void ffPrintDesktopEnvironment(FFinstance* instance)
}
else
{
ffPrintFormatString(instance, "DE", &instance->config.deFormat, 3,
ffPrintFormatString(instance, &instance->config.deFormat, "DE", &instance->config.deFormat, 3,
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &sessionDesktop},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &sessionVersion},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &sessionType}
+31 -12
View File
@@ -2,7 +2,7 @@
#include <sys/statvfs.h>
static void printStatvfs(FFinstance* instance, const char* key, struct statvfs* fs)
static void printStatvfs(FFinstance* instance, FFstrbuf* key, struct statvfs* fs)
{
const uint32_t GB = 1024 * 1024 * 1024;
@@ -15,12 +15,12 @@ static void printStatvfs(FFinstance* instance, const char* key, struct statvfs*
if(instance->config.diskFormat.length == 0)
{
ffPrintLogoAndKey(instance, key);
ffPrintLogoAndKey(instance, key, NULL);
printf("%uGB / %uGB (%u%%)\n", used, total, percentage);
}
else
{
ffPrintFormatString(instance, key, &instance->config.diskFormat, 4,
ffPrintFormatString(instance, key, NULL, &instance->config.diskFormat, 4,
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &used},
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &total},
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &files},
@@ -29,24 +29,43 @@ static void printStatvfs(FFinstance* instance, const char* key, struct statvfs*
}
}
static void createKey(FFinstance* instance, FFstrbuf* key, const char* folderPath)
{
if(instance->config.diskKey.length == 0)
{
ffStrbufAppendF(key, "Disk (%s)", folderPath);
}
else
{
ffParseFormatString(key, &instance->config.diskKey, 1,
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, folderPath}
);
}
}
static void printStatvfsCreateKey(FFinstance* instance, const char* folderPath, struct statvfs* fs)
{
FF_STRBUF_CREATE(key);
createKey(instance, &key, folderPath);
printStatvfs(instance, &key, fs);
ffStrbufDestroy(&key);
}
static void printFolder(FFinstance* instance, const char* folderPath)
{
FF_STRBUF_CREATE(key);
ffStrbufAppendS(&key, "Disk (");
ffStrbufAppendS(&key, folderPath);
ffStrbufAppendC(&key, ')');
createKey(instance, &key, folderPath);
struct statvfs fs;
int ret = statvfs(folderPath, &fs);
if(ret != 0 && instance->config.diskFormat.length == 0)
{
ffPrintError(instance, key.chars, "statvfs(\"%s\", &fs) != 0", folderPath);
ffPrintError(instance, &key, NULL, "statvfs(\"%s\", &fs) != 0", folderPath);
ffStrbufDestroy(&key);
return;
}
printStatvfs(instance, key.chars, &fs);
printStatvfs(instance, &key, &fs);
ffStrbufDestroy(&key);
}
@@ -62,15 +81,15 @@ void ffPrintDisk(FFinstance* instance)
if(rootRet != 0 && homeRet != 0)
{
ffPrintError(instance, "Disk", "statvfs failed for both / and /home");
ffPrintError(instance, NULL, "Disk", "statvfs failed for both / and /home");
return;
}
if(rootRet == 0)
printStatvfs(instance, "Disk (/)", &fsRoot);
printStatvfsCreateKey(instance, "/", &fsRoot);
if(homeRet == 0 && (rootRet != 0 || fsRoot.f_fsid != fsHome.f_fsid))
printStatvfs(instance, "Disk (/home)", &fsHome);
printStatvfsCreateKey(instance, "/home", &fsHome);
}
else
{
+2 -2
View File
@@ -43,13 +43,13 @@ void ffPrintFont(FFinstance* instance)
if(instance->config.fontFormat.length == 0)
{
ffPrintLogoAndKey(instance, "Font");
ffPrintLogoAndKey(instance, &instance->config.fontKey, "Font");
printf("%s [Plasma], ", plasmaPretty);
ffStrbufPutTo(&gtkPretty, stdout);
}
else
{
ffPrintFormatString(instance, "Font", &instance->config.fontFormat, 5,
ffPrintFormatString(instance, &instance->config.fontKey, "Font", &instance->config.fontFormat, 5,
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, plasmaPretty},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, gtk2Pretty},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, gtk3Pretty},
+26 -13
View File
@@ -3,12 +3,24 @@
#include <pci/pci.h>
#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, ...))
static void handleGPU(FFinstance* instance, struct pci_access* pacc, struct pci_dev* dev, uint32_t counter, char*(*ffpci_lookup_name)(struct pci_access*, char*, int, int, ...))
{
char key[8];
sprintf(key, "GPU%hu", counter);
char cacheKey[8];
sprintf(cacheKey, "GPU%u", counter);
if(ffPrintCachedValue(instance, key))
FF_STRBUF_CREATE(key);
if(instance->config.gpuKey.length == 0)
{
ffStrbufAppendF(&key, "GPU %u", counter);
}
else
{
ffParseFormatString(&key, &instance->config.gpuKey, 1,
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &counter}
);
}
if(ffPrintCachedValue(instance, &key, cacheKey))
return;
char vendor[512];
@@ -37,8 +49,9 @@ static void handleGPU(FFinstance* instance, struct pci_access* pacc, struct pci_
);
}
ffPrintAndSaveCachedValue(instance, key, &gpu);
ffPrintAndSaveCachedValue(instance, &key, cacheKey, &gpu);
ffStrbufDestroy(&gpu);
ffStrbufDestroy(&key);
}
void ffPrintGPU(FFinstance* instance)
@@ -50,53 +63,53 @@ void ffPrintGPU(FFinstance* instance)
pci = dlopen(instance->config.libPCI.chars, RTLD_LAZY);
if(pci == NULL)
{
ffPrintError(instance, "GPU", "dlopen(\"libpci.so\", RTLD_LAZY) == NULL");
ffPrintError(instance, NULL, "GPU", "dlopen(\"libpci.so\", RTLD_LAZY) == NULL");
return;
}
struct pci_access*(*ffpci_alloc)() = dlsym(pci, "pci_alloc");
if(ffpci_alloc == NULL)
{
ffPrintError(instance, "GPU", "dlsym(pci, \"pci_alloc\") == NULL");
ffPrintError(instance, NULL, "GPU", "dlsym(pci, \"pci_alloc\") == NULL");
return;
}
void(*ffpci_init)(struct pci_access*) = dlsym(pci, "pci_init");
if(ffpci_init == NULL)
{
ffPrintError(instance, "GPU", "dlsym(pci, \"pci_init\") == NULL");
ffPrintError(instance, NULL, "GPU", "dlsym(pci, \"pci_init\") == NULL");
return;
}
void(*ffpci_scan_bus)(struct pci_access*) = dlsym(pci, "pci_scan_bus");
if(ffpci_scan_bus == NULL)
{
ffPrintError(instance, "GPU", "dlsym(pci, \"pci_init\") == NULL");
ffPrintError(instance, NULL, "GPU", "dlsym(pci, \"pci_init\") == NULL");
return;
}
int(*ffpci_fill_info)(struct pci_dev*, int) = dlsym(pci, "pci_fill_info");
if(ffpci_fill_info == NULL)
{
ffPrintError(instance, "GPU", "dlsym(pci, \"pci_fill_info\") == NULL");
ffPrintError(instance, NULL, "GPU", "dlsym(pci, \"pci_fill_info\") == NULL");
return;
}
char*(*ffpci_lookup_name)(struct pci_access*, char*, int, int, ...) = dlsym(pci, "pci_lookup_name");
if(ffpci_lookup_name == NULL)
{
ffPrintError(instance, "GPU", "dlsym(pci, \"pci_lookup_name\") == NULL");
ffPrintError(instance, NULL, "GPU", "dlsym(pci, \"pci_lookup_name\") == NULL");
return;
}
void(*ffpci_cleanup)(struct pci_access*) = dlsym(pci, "pci_cleanup");
if(ffpci_cleanup == NULL)
{
ffPrintError(instance, "GPU", "dlsym(pci, \"pci_cleanup\") == NULL");
ffPrintError(instance, NULL, "GPU", "dlsym(pci, \"pci_cleanup\") == NULL");
return;
}
uint16_t counter = 0;
uint32_t counter = 0;
struct pci_access *pacc;
struct pci_dev *dev;
+3 -3
View File
@@ -2,7 +2,7 @@
void ffPrintHost(FFinstance* instance)
{
if(ffPrintCachedValue(instance, "Host"))
if(ffPrintCachedValue(instance, &instance->config.hostKey, "Host"))
return;
FF_STRBUF_CREATE(family);
@@ -20,7 +20,7 @@ void ffPrintHost(FFinstance* instance)
{
if(family.length == 0 && name.length == 0)
{
ffPrintError(instance, "Host", "neither family nor name could be determined");
ffPrintError(instance, &instance->config.hostKey, "Host", "neither family nor name could be determined");
return;
}
else if(name.length == 0)
@@ -56,7 +56,7 @@ void ffPrintHost(FFinstance* instance)
);
}
ffPrintAndSaveCachedValue(instance, "Host", &host);
ffPrintAndSaveCachedValue(instance, &instance->config.hostKey, "Host", &host);
ffStrbufDestroy(&host);
ffStrbufDestroy(&family);
+2 -2
View File
@@ -25,7 +25,7 @@ void ffPrintIcons(FFinstance* instance)
if(instance->config.iconsFormat.length == 0)
{
ffPrintLogoAndKey(instance, "Icons");
ffPrintLogoAndKey(instance, &instance->config.iconsKey, "Icons");
if(plasma[0] == '\0')
printf("Breeze [Plasma], ");
@@ -36,7 +36,7 @@ void ffPrintIcons(FFinstance* instance)
}
else
{
ffPrintFormatString(instance, "Icons", &instance->config.iconsFormat, 5,
ffPrintFormatString(instance, &instance->config.iconsKey, "Icons", &instance->config.iconsFormat, 5,
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, plasma},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, gtk2},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, gtk3},
+2 -2
View File
@@ -4,12 +4,12 @@ void ffPrintKernel(FFinstance* instance)
{
if(instance->config.kernelFormat.length == 0)
{
ffPrintLogoAndKey(instance, "Kernel");
ffPrintLogoAndKey(instance, &instance->config.kernelKey, "Kernel");
puts(instance->state.utsname.release);
}
else
{
ffPrintFormatString(instance, "Kernel", &instance->config.kernelFormat, 3,
ffPrintFormatString(instance, &instance->config.kernelKey, "Kernel", &instance->config.kernelFormat, 3,
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.sysname},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.release},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.version}
+3 -3
View File
@@ -2,7 +2,7 @@
void ffPrintLocale(FFinstance* instance)
{
if(ffPrintCachedValue(instance, "Locale"))
if(ffPrintCachedValue(instance, &instance->config.localeKey, "Locale"))
return;
char localeCode[256];
@@ -30,7 +30,7 @@ void ffPrintLocale(FFinstance* instance)
strcpy(localeCode, getenv("LC_MESSAGES"));
/* User has broken system */
else
ffPrintError(instance, "Locale", "Locale not found!");
ffPrintError(instance, &instance->config.localeKey, "Locale", "Locale not found!");
/* /etc/locale.conf exists */
} else {
ffParsePropFile("/etc/locale.conf", "LANG=%[^\n]", localeCode);
@@ -52,6 +52,6 @@ void ffPrintLocale(FFinstance* instance)
);
}
ffPrintAndSaveCachedValue(instance, "Locale", &locale);
ffPrintAndSaveCachedValue(instance, &instance->config.localeKey, "Locale", &locale);
ffStrbufDestroy(&locale);
}
+3 -3
View File
@@ -5,7 +5,7 @@ void ffPrintMemory(FFinstance* instance)
{
FILE* meminfo = fopen("/proc/meminfo", "r");
if(meminfo == NULL) {
ffPrintError(instance, "Memory", "fopen(\"/proc/meminfo\", \"r\") == NULL");
ffPrintError(instance, &instance->config.memoryKey, "Memory", "fopen(\"/proc/meminfo\", \"r\") == NULL");
return;
}
@@ -32,12 +32,12 @@ void ffPrintMemory(FFinstance* instance)
if(instance->config.memoryFormat.length == 0)
{
ffPrintLogoAndKey(instance, "Memory");
ffPrintLogoAndKey(instance, &instance->config.memoryKey, "Memory");
printf("%uMiB / %uMiB (%u%%)\n", used_mem, total_mem, percentage);
}
else
{
ffPrintFormatString(instance, "Memory", &instance->config.memoryFormat, 3,
ffPrintFormatString(instance, &instance->config.memoryKey, "Memory", &instance->config.memoryFormat, 3,
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &used_mem},
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &total_mem},
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT8, &percentage}
+2 -2
View File
@@ -2,7 +2,7 @@
void ffPrintOS(FFinstance* instance)
{
if(ffPrintCachedValue(instance, "OS"))
if(ffPrintCachedValue(instance, &instance->config.osKey, "OS"))
return;
// Documentation of the fields:
@@ -124,6 +124,6 @@ void ffPrintOS(FFinstance* instance)
);
}
ffPrintAndSaveCachedValue(instance, "OS", &os);
ffPrintAndSaveCachedValue(instance, &instance->config.osKey, "OS", &os);
ffStrbufDestroy(&os);
}
+3 -3
View File
@@ -34,11 +34,11 @@ void ffPrintPackages(FFinstance* instance)
{
if(all == 0)
{
ffPrintError(instance, "Packages", "No packages from known package managers found");
ffPrintError(instance, &instance->config.packagesKey, "Packages", "No packages from known package managers found");
return;
}
ffPrintLogoAndKey(instance, "Packages");
ffPrintLogoAndKey(instance, &instance->config.packagesKey, "Packages");
#define FF_PRINT_PACKAGE(name) \
if(name > 0) \
@@ -57,7 +57,7 @@ void ffPrintPackages(FFinstance* instance)
}
else
{
ffPrintFormatString(instance, "Packages", &instance->config.packagesFormat, 3,
ffPrintFormatString(instance, &instance->config.packagesKey, "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}
+5 -5
View File
@@ -40,7 +40,7 @@ static int getCurrentRate(FFinstance* instance, Display* display)
void ffPrintResolution(FFinstance* instance)
{
if(ffPrintCachedValue(instance, "Resolution"))
if(ffPrintCachedValue(instance, &instance->config.resolutionFormat, "Resolution"))
return;
void* x11;
@@ -50,21 +50,21 @@ void ffPrintResolution(FFinstance* instance)
x11 = dlopen(instance->config.libX11.chars, RTLD_LAZY);
if(x11 == NULL)
{
ffPrintError(instance, "Resolution", "dlopen(\"libX11.so\", RTLD_LAZY) == NULL");
ffPrintError(instance, &instance->config.resolutionFormat, "Resolution", "dlopen(\"libX11.so\", RTLD_LAZY) == NULL");
return;
}
Display*(*ffXOpenDisplay)(const char*) = dlsym(x11, "XOpenDisplay");
if(ffXOpenDisplay == NULL)
{
ffPrintError(instance, "Resolution", "dlsym(x11, \"XOpenDisplay\") == NULL");
ffPrintError(instance, &instance->config.resolutionFormat, "Resolution", "dlsym(x11, \"XOpenDisplay\") == NULL");
return;
}
Display* display = ffXOpenDisplay(NULL);
if(display == NULL)
{
ffPrintError(instance, "Resolution", "ffXOpenDisplay(NULL) == NULL");
ffPrintError(instance, &instance->config.resolutionFormat, "Resolution", "ffXOpenDisplay(NULL) == NULL");
return;
}
@@ -92,6 +92,6 @@ void ffPrintResolution(FFinstance* instance)
);
}
ffPrintAndSaveCachedValue(instance, "Resolution", &resolution);
ffPrintAndSaveCachedValue(instance, &instance->config.resolutionKey, "Resolution", &resolution);
ffStrbufDestroy(&resolution);
}
+3 -3
View File
@@ -2,13 +2,13 @@
void ffPrintShell(FFinstance* instance)
{
if(ffPrintCachedValue(instance, "Shell"))
if(ffPrintCachedValue(instance, &instance->config.shellKey, "Shell"))
return;
char* shellPath = getenv("SHELL");
if(shellPath == NULL)
{
ffPrintError(instance, "Shell", "getenv(\"SHELL\") == NULL");
ffPrintError(instance, &instance->config.shellKey, "Shell", "getenv(\"SHELL\") == NULL");
return;
}
@@ -41,6 +41,6 @@ void ffPrintShell(FFinstance* instance)
);
}
ffPrintAndSaveCachedValue(instance, "Shell", &shell);
ffPrintAndSaveCachedValue(instance, &instance->config.shellKey, "Shell", &shell);
ffStrbufDestroy(&shell);
}
+3 -3
View File
@@ -96,16 +96,16 @@ void ffPrintTerminal(FFinstance* instance)
{
if(error->length > 0)
{
ffPrintError(instance, "Terminal", error->chars);
ffPrintError(instance, &instance->config.terminalKey, "Terminal", error->chars);
return;
}
ffPrintLogoAndKey(instance, "Terminal");
ffPrintLogoAndKey(instance, &instance->config.terminalKey, "Terminal");
ffStrbufPutTo(name, stdout);
}
else
{
ffPrintFormatString(instance, "Terminal", &instance->config.terminalFormat, 3,
ffPrintFormatString(instance, &instance->config.terminalKey, "Terminal", &instance->config.terminalFormat, 3,
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, exeName},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, processName},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, name}
+6 -6
View File
@@ -4,12 +4,12 @@ static void printTerminalFont(FFinstance* instance, char* font)
{
if(instance->config.termFontFormat.length == 0)
{
ffPrintLogoAndKey(instance, "Terminal font");
ffPrintLogoAndKey(instance, &instance->config.termFontKey, "Terminal font");
puts(font);
}
else
{
ffPrintFormatString(instance, "Terminal font", &instance->config.termFontFormat, 1,
ffPrintFormatString(instance, &instance->config.termFontKey, "Terminal font", &instance->config.termFontFormat, 1,
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, font}
);
}
@@ -21,7 +21,7 @@ static void printKonsole(FFinstance* instance)
ffParsePropFileHome(instance, ".config/konsolerc", "DefaultProfile=%[^\n]", profile);
if(profile[0] == '\0')
{
ffPrintError(instance, "Terminal Font", "Couldn't find \"DefaultProfile=%[^\n]\" in \".config/konsolerc\"");
ffPrintError(instance, &instance->config.termFontKey, "Terminal Font", "Couldn't find \"DefaultProfile=%[^\n]\" in \".config/konsolerc\"");
return;
}
@@ -32,7 +32,7 @@ static void printKonsole(FFinstance* instance)
ffParsePropFileHome(instance, profilePath, "Font=%[^\n]", font);
if(font[0] == '\0')
{
ffPrintError(instance, "Terminal Font", "Couldn't find \"Font=%%[^\\n]\" in \"%s\"", profilePath);
ffPrintError(instance, &instance->config.termFontKey, "Terminal Font", "Couldn't find \"Font=%%[^\\n]\" in \"%s\"", profilePath);
return;
}
@@ -61,7 +61,7 @@ void ffPrintTerminalFont(FFinstance* instance)
if(error->length > 0)
{
if(instance->config.termFontFormat.length == 0)
ffPrintError(instance, "Terminal Font", "Terminal Font needs successfull terminal detection");
ffPrintError(instance, &instance->config.termFontKey, "Terminal Font", "Terminal Font needs successfull terminal detection");
else
printTerminalFont(instance, "");
@@ -77,6 +77,6 @@ void ffPrintTerminalFont(FFinstance* instance)
if(instance->config.termFontFormat.length > 0)
printTerminalFont(instance, "");
else
ffPrintError(instance, "Terminal Font", "Unknown terminal: %s", error->chars);
ffPrintError(instance, &instance->config.termFontKey, "Terminal Font", "Unknown terminal: %s", error->chars);
}
}
+2 -2
View File
@@ -25,7 +25,7 @@ void ffPrintTheme(FFinstance* instance)
if(instance->config.themeFormat.length == 0)
{
ffPrintLogoAndKey(instance, "Theme");
ffPrintLogoAndKey(instance, &instance->config.themeKey, "Theme");
if(plasma[0] != '\0')
printf("%s [Plasma], ", plasma);
@@ -34,7 +34,7 @@ void ffPrintTheme(FFinstance* instance)
}
else
{
ffPrintFormatString(instance, "Theme", &instance->config.themeFormat, 5,
ffPrintFormatString(instance, &instance->config.themeKey, "Theme", &instance->config.themeFormat, 5,
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, plasma},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, gtk2},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, gtk3},
+2 -2
View File
@@ -9,7 +9,7 @@ void ffPrintUptime(FFinstance* instance)
if(instance->config.uptimeFormat.length == 0)
{
ffPrintLogoAndKey(instance, "Uptime");
ffPrintLogoAndKey(instance, &instance->config.uptimeKey, "Uptime");
if(days == 0 && hours == 0 && minutes == 0)
{
@@ -28,7 +28,7 @@ void ffPrintUptime(FFinstance* instance)
}
else
{
ffPrintFormatString(instance, "Uptime", &instance->config.uptimeFormat, 4,
ffPrintFormatString(instance, &instance->config.uptimeKey, "Uptime", &instance->config.uptimeFormat, 4,
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &days},
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &hours},
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &minutes},
+4 -4
View File
@@ -7,7 +7,7 @@ void ffPrintWM(FFinstance* instance)
DIR* proc = opendir("/proc/");
if(proc == NULL)
{
ffPrintError(instance, "WM", "opendir(\"/proc/\") == NULL");
ffPrintError(instance, &instance->config.wmKey, "WM", "opendir(\"/proc/\") == NULL");
return;
}
@@ -39,16 +39,16 @@ void ffPrintWM(FFinstance* instance)
{
if(prettyName.length == 0)
{
ffPrintError(instance, "WM", "No process name matches the name of known display managers");
ffPrintError(instance, &instance->config.wmKey, "WM", "No process name matches the name of known display managers");
return;
}
ffPrintLogoAndKey(instance, "WM");
ffPrintLogoAndKey(instance, &instance->config.wmKey, "WM");
ffStrbufPutTo(&prettyName, stdout);
}
else
{
ffPrintFormatString(instance, "WM", &instance->config.wmFormat, 2,
ffPrintFormatString(instance, &instance->config.wmKey, "WM", &instance->config.wmFormat, 2,
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &processName},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &prettyName}
);