merged changes

This commit is contained in:
Linus Dierheimer
2021-04-28 19:54:03 +02:00
2 changed files with 21 additions and 16 deletions
+6 -5
View File
@@ -120,9 +120,9 @@ static inline void printHelp()
" --disk-folders <folders>: A colon seperated list of folder paths for the disk output. Default is \"/:/home\"\n"
" --battery-dir <folder>: The directory were the battery folders are in. Standard: /sys/class/power_supply/\n"
"\n"
"Parsing is not case sensetive. E.g. \"--lib-PCI\" is equal to \"--Lib-Pci\"\n"
"If an value starts with an ?, it is optional. \"true\" will be used if not set.\n"
"An (+) at the end indicates that more help can be printed with --help <option>\n"
"Parsing is not case sensitive. E.g. \"--lib-PCI\" is equal to \"--Lib-Pci\"\n"
"If a value starts with a ?, it is optional. \"true\" will be used if not set.\n"
"A (+) at the end indicates that more help can be printed with --help <option>\n"
"All options can be make permanent in $XDG_CONFIG_HOME/fastfetch/config.conf"
);
}
@@ -275,10 +275,11 @@ static inline void printCommandHelp(const char* command)
}
else if(strcasecmp(command, "packages-format") == 0)
{
constructAndPrintCommandHelpFormat("packages", "{2} (pacman), {3} (flatpak)", 3,
constructAndPrintCommandHelpFormat("packages", "{2} (pacman), {3} (flatpak), {4} (xbps)", 4,
"Number of all packages",
"Number of pacman packages",
"Number of flatpak packages"
"Number of flatpak packages",
"Number of xbps packages"
);
}
else if(strcasecmp(command, "shell-format") == 0)
+15 -11
View File
@@ -3,10 +3,10 @@
#include <dirent.h>
#define FF_PACKAGES_MODULE_NAME "Packages"
#define FF_PACKAGES_NUM_FORMAT_ARGS 3
#define FF_PACKAGES_NUM_FORMAT_ARGS 4
static uint32_t get_num_dirs(const char* dirname) {
uint32_t num_dirs = 0;
static uint32_t get_num_elements(const char* dirname, unsigned char type) {
uint32_t num_elements = 0;
DIR * dirp;
struct dirent *entry;
@@ -15,23 +15,25 @@ static uint32_t get_num_dirs(const char* dirname) {
return 0;
while((entry = readdir(dirp)) != NULL) {
if(entry->d_type == DT_DIR)
++num_dirs;
if(entry->d_type == type)
++num_elements;
}
num_dirs -= 2; // accounting for . and ..
if(type == DT_DIR)
num_elements -= 2; // accounting for . and ..
closedir(dirp);
return num_dirs;
return num_elements;
}
void ffPrintPackages(FFinstance* instance)
{
uint32_t pacman = get_num_dirs("/var/lib/pacman/local");
uint32_t flatpak = get_num_dirs("/var/lib/flatpak/app");
uint32_t pacman = get_num_elements("/var/lib/pacman/local", DT_DIR);
uint32_t flatpak = get_num_elements("/var/lib/flatpak/app", DT_DIR);
uint32_t xbps = get_num_elements("/var/db/xbps", DT_REG);
uint32_t all = pacman + flatpak;
uint32_t all = pacman + flatpak + xbps;
if(all == 0)
{
@@ -53,6 +55,7 @@ void ffPrintPackages(FFinstance* instance)
FF_PRINT_PACKAGE(pacman)
FF_PRINT_PACKAGE(flatpak)
FF_PRINT_PACKAGE(xbps)
#undef FF_PRINT_PACKAGE
@@ -63,7 +66,8 @@ void ffPrintPackages(FFinstance* instance)
ffPrintFormatString(instance, FF_PACKAGES_MODULE_NAME, 0, &instance->config.packagesKey, &instance->config.packagesFormat, NULL, FF_PACKAGES_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT, &all},
{FF_FORMAT_ARG_TYPE_UINT, &pacman},
{FF_FORMAT_ARG_TYPE_UINT, &flatpak}
{FF_FORMAT_ARG_TYPE_UINT, &flatpak},
{FF_FORMAT_ARG_TYPE_UINT, &xbps}
});
}
}