mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-03 11:44:18 +01:00
Fastfetch: refactor the code of --list-modules
This commit is contained in:
+1
-1
@@ -211,7 +211,6 @@ fastfetch_load_text(src/data/structure.txt DATATEXT_STRUCTURE)
|
||||
fastfetch_load_text(src/data/config_system.txt DATATEXT_CONFIG_SYSTEM)
|
||||
fastfetch_load_text(src/data/config_user.txt DATATEXT_CONFIG_USER)
|
||||
fastfetch_load_text(src/data/config_user.jsonc DATATEXT_CONFIG_USER_JSONC)
|
||||
fastfetch_load_text(src/data/modules.txt DATATEXT_MODULES)
|
||||
fastfetch_load_text(src/data/help.txt DATATEXT_HELP)
|
||||
fastfetch_load_text(src/data/help_color.txt DATATEXT_HELP_COLOR)
|
||||
fastfetch_load_text(src/data/help_format.txt DATATEXT_HELP_FORMAT)
|
||||
@@ -259,6 +258,7 @@ set(LIBFASTFETCH_SRC
|
||||
src/common/init.c
|
||||
src/common/jsonconfig.c
|
||||
src/common/library.c
|
||||
src/common/modules.c
|
||||
src/common/option.c
|
||||
src/common/parsing.c
|
||||
src/common/printing.c
|
||||
|
||||
@@ -96,7 +96,7 @@ All categories not listed here should work without needing a specific implementa
|
||||
|
||||
##### Available Modules
|
||||
```
|
||||
Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, LM, Locale, LocalIP, Media, Memory, Monitor, OpenCL, OpenGL, Packages, Player, Power Adapter, Processes, PublicIP, Separator, OS, Shell, Sound, Swap, Terminal, Terminal Font, Terminal Size, Theme, Time, Title, Uptime, Vulkan, Wallpaper, Wifi, WM, WMTheme
|
||||
Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, LM, Locale, LocalIP, Media, Memory, Monitor, OpenCL, OpenGL, OS, Packages, Player, Power Adapter, Processes, PublicIP, Separator, Shell, Sound, Swap, Terminal, Terminal Font, Terminal Size, Theme, Time, Title, Uptime, Vulkan, Wallpaper, Weather, Wifi, WM, WMTheme
|
||||
```
|
||||
|
||||
##### Builtin logos
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
#include "fastfetch.h"
|
||||
|
||||
static FFModuleBaseInfo* A[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* B[] = {
|
||||
(void*) &instance.config.battery,
|
||||
(void*) &instance.config.bios,
|
||||
(void*) &instance.config.bluetooth,
|
||||
(void*) &instance.config.board,
|
||||
(void*) &instance.config.break_,
|
||||
(void*) &instance.config.brightness,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* C[] = {
|
||||
(void*) &instance.config.chassis,
|
||||
(void*) &instance.config.command,
|
||||
(void*) &instance.config.colors,
|
||||
(void*) &instance.config.cpu,
|
||||
(void*) &instance.config.cpuUsage,
|
||||
(void*) &instance.config.cursor,
|
||||
(void*) &instance.config.custom,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* D[] = {
|
||||
(void*) &instance.config.dateTime,
|
||||
(void*) &instance.config.de,
|
||||
(void*) &instance.config.display,
|
||||
(void*) &instance.config.disk,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* E[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* F[] = {
|
||||
(void*) &instance.config.font,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* G[] = {
|
||||
(void*) &instance.config.gamepad,
|
||||
(void*) &instance.config.gpu,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* H[] = {
|
||||
(void*) &instance.config.host,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* I[] = {
|
||||
(void*) &instance.config.icons,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* J[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* K[] = {
|
||||
(void*) &instance.config.kernel,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* L[] = {
|
||||
(void*) &instance.config.lm,
|
||||
(void*) &instance.config.locale,
|
||||
(void*) &instance.config.localIP,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* M[] = {
|
||||
(void*) &instance.config.media,
|
||||
(void*) &instance.config.memory,
|
||||
(void*) &instance.config.monitor,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* N[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* O[] = {
|
||||
(void*) &instance.config.openCL,
|
||||
(void*) &instance.config.openGL,
|
||||
(void*) &instance.config.os,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* P[] = {
|
||||
(void*) &instance.config.packages,
|
||||
(void*) &instance.config.player,
|
||||
(void*) &instance.config.powerAdapter,
|
||||
(void*) &instance.config.processes,
|
||||
(void*) &instance.config.publicIP,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* Q[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* R[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* S[] = {
|
||||
(void*) &instance.config.separator,
|
||||
(void*) &instance.config.shell,
|
||||
(void*) &instance.config.sound,
|
||||
(void*) &instance.config.swap,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* T[] = {
|
||||
(void*) &instance.config.terminal,
|
||||
(void*) &instance.config.terminalFont,
|
||||
(void*) &instance.config.terminalSize,
|
||||
(void*) &instance.config.title,
|
||||
(void*) &instance.config.theme,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* U[] = {
|
||||
(void*) &instance.config.uptime,
|
||||
(void*) &instance.config.users,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* V[] = {
|
||||
(void*) &instance.config.vulkan,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* W[] = {
|
||||
(void*) &instance.config.wallpaper,
|
||||
(void*) &instance.config.weather,
|
||||
(void*) &instance.config.wm,
|
||||
(void*) &instance.config.wifi,
|
||||
(void*) &instance.config.wmTheme,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* X[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* Y[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* Z[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
FFModuleBaseInfo** ffModuleInfos[] = {
|
||||
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z,
|
||||
};
|
||||
@@ -1,45 +0,0 @@
|
||||
Battery
|
||||
Bios
|
||||
Bluetooth
|
||||
Board
|
||||
Break
|
||||
Chassis
|
||||
Colors
|
||||
CPU
|
||||
CPUUsage
|
||||
Cursor
|
||||
Date
|
||||
Datetime
|
||||
DE
|
||||
Disk
|
||||
Display
|
||||
Font
|
||||
GPU
|
||||
Host
|
||||
Icons
|
||||
Kernel
|
||||
Locale
|
||||
LocalIP
|
||||
Media
|
||||
Memory
|
||||
OpenGL
|
||||
OS
|
||||
Packages
|
||||
Player
|
||||
PowerAdapter
|
||||
Processes
|
||||
PublicIP
|
||||
Separator
|
||||
Shell
|
||||
Swap
|
||||
Terminal
|
||||
TerminalFont
|
||||
Theme
|
||||
Time
|
||||
Title
|
||||
Uptime
|
||||
Vulkan
|
||||
Weather
|
||||
Wifi
|
||||
WM
|
||||
WMTheme
|
||||
+14
-1
@@ -554,6 +554,19 @@ static void listDataPaths(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void listModules()
|
||||
{
|
||||
unsigned count = 0;
|
||||
for (int i = 0; i <= 'Z' - 'A'; ++i)
|
||||
{
|
||||
for (FFModuleBaseInfo** modules = ffModuleInfos[i]; *modules; ++modules)
|
||||
{
|
||||
++count;
|
||||
printf("%d)%s%s\n", count, count > 9 ? " " : " ", (*modules)->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void parseOption(FFdata* data, const char* key, const char* value);
|
||||
|
||||
static bool parseJsoncFile(const char* path)
|
||||
@@ -856,7 +869,7 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
||||
const char* subkey = key + strlen("--list");
|
||||
if(ffStrEqualsIgnCase(subkey, "-modules"))
|
||||
{
|
||||
puts(FASTFETCH_DATATEXT_MODULES);
|
||||
listModules();
|
||||
exit(0);
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subkey, "-presets"))
|
||||
|
||||
+49
-48
@@ -78,60 +78,60 @@ typedef struct FFconfig
|
||||
int32_t wmiTimeout;
|
||||
#endif
|
||||
|
||||
FFTitleOptions title;
|
||||
FFOSOptions os;
|
||||
FFHostOptions host;
|
||||
FFBatteryOptions battery;
|
||||
FFBiosOptions bios;
|
||||
FFBluetoothOptions bluetooth;
|
||||
FFBoardOptions board;
|
||||
FFBreakOptions break_;
|
||||
FFBrightnessOptions brightness;
|
||||
FFChassisOptions chassis;
|
||||
FFCommandOptions command;
|
||||
FFKernelOptions kernel;
|
||||
FFUptimeOptions uptime;
|
||||
FFProcessesOptions processes;
|
||||
FFPackagesOptions packages;
|
||||
FFShellOptions shell;
|
||||
FFDisplayOptions display;
|
||||
FFDEOptions de;
|
||||
FFWallpaperOptions wallpaper;
|
||||
FFWifiOptions wifi;
|
||||
FFWMOptions wm;
|
||||
FFWMThemeOptions wmTheme;
|
||||
FFThemeOptions theme;
|
||||
FFIconsOptions icons;
|
||||
FFFontOptions font;
|
||||
FFCursorOptions cursor;
|
||||
FFTerminalOptions terminal;
|
||||
FFTerminalFontOptions terminalFont;
|
||||
FFTerminalSizeOptions terminalSize;
|
||||
FFCPUOptions cpu;
|
||||
FFCPUUsageOptions cpuUsage;
|
||||
FFCustomOptions custom;
|
||||
FFGPUOptions gpu;
|
||||
FFMemoryOptions memory;
|
||||
FFSwapOptions swap;
|
||||
FFDiskOptions disk;
|
||||
FFBatteryOptions battery;
|
||||
FFPowerAdapterOptions powerAdapter;
|
||||
FFLMOptions lm;
|
||||
FFLocaleOptions locale;
|
||||
FFLocalIpOptions localIP;
|
||||
FFPublicIpOptions publicIP;
|
||||
FFWeatherOptions weather;
|
||||
FFPlayerOptions player;
|
||||
FFMediaOptions media;
|
||||
FFMonitorOptions monitor;
|
||||
FFDateTimeOptions dateTime;
|
||||
FFVulkanOptions vulkan;
|
||||
FFOpenGLOptions openGL;
|
||||
FFOpenCLOptions openCL;
|
||||
FFUsersOptions users;
|
||||
FFBluetoothOptions bluetooth;
|
||||
FFSeparatorOptions separator;
|
||||
FFSoundOptions sound;
|
||||
FFGamepadOptions gamepad;
|
||||
FFBreakOptions break_;
|
||||
FFChassisOptions chassis;
|
||||
FFColorsOptions colors;
|
||||
FFCommandOptions command;
|
||||
FFCursorOptions cursor;
|
||||
FFCustomOptions custom;
|
||||
FFDEOptions de;
|
||||
FFDateTimeOptions dateTime;
|
||||
FFDiskOptions disk;
|
||||
FFDisplayOptions display;
|
||||
FFFontOptions font;
|
||||
FFGPUOptions gpu;
|
||||
FFGamepadOptions gamepad;
|
||||
FFHostOptions host;
|
||||
FFIconsOptions icons;
|
||||
FFKernelOptions kernel;
|
||||
FFLMOptions lm;
|
||||
FFLocalIpOptions localIP;
|
||||
FFLocaleOptions locale;
|
||||
FFMediaOptions media;
|
||||
FFMemoryOptions memory;
|
||||
FFMonitorOptions monitor;
|
||||
FFOSOptions os;
|
||||
FFOpenCLOptions openCL;
|
||||
FFOpenGLOptions openGL;
|
||||
FFPackagesOptions packages;
|
||||
FFPlayerOptions player;
|
||||
FFPowerAdapterOptions powerAdapter;
|
||||
FFProcessesOptions processes;
|
||||
FFPublicIpOptions publicIP;
|
||||
FFSeparatorOptions separator;
|
||||
FFShellOptions shell;
|
||||
FFSoundOptions sound;
|
||||
FFSwapOptions swap;
|
||||
FFTerminalFontOptions terminalFont;
|
||||
FFTerminalOptions terminal;
|
||||
FFTerminalSizeOptions terminalSize;
|
||||
FFThemeOptions theme;
|
||||
FFTitleOptions title;
|
||||
FFUptimeOptions uptime;
|
||||
FFUsersOptions users;
|
||||
FFVulkanOptions vulkan;
|
||||
FFWMOptions wm;
|
||||
FFWMThemeOptions wmTheme;
|
||||
FFWallpaperOptions wallpaper;
|
||||
FFWeatherOptions weather;
|
||||
FFWifiOptions wifi;
|
||||
|
||||
FFstrbuf libPCI;
|
||||
FFstrbuf libVulkan;
|
||||
@@ -175,6 +175,7 @@ typedef struct FFinstance
|
||||
FFstate state;
|
||||
} FFinstance;
|
||||
extern FFinstance instance; // Defined in `common/init.c`
|
||||
extern FFModuleBaseInfo** ffModuleInfos[];
|
||||
|
||||
//////////////////////
|
||||
// Init functions //
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#define FASTFETCH_DATATEXT_CONFIG_SYSTEM "@DATATEXT_CONFIG_SYSTEM@"
|
||||
#define FASTFETCH_DATATEXT_CONFIG_USER "@DATATEXT_CONFIG_USER@" //Requires FASTFETCH_PROJECT_VERSION and FASTFETCH_DATATEXT_STRUCTURE to be set
|
||||
#define FASTFETCH_DATATEXT_CONFIG_USER_JSONC "@DATATEXT_CONFIG_USER_JSONC@"
|
||||
#define FASTFETCH_DATATEXT_MODULES "@DATATEXT_MODULES@"
|
||||
#define FASTFETCH_DATATEXT_HELP "@DATATEXT_HELP@"
|
||||
#define FASTFETCH_DATATEXT_HELP_COLOR "@DATATEXT_HELP_COLOR@"
|
||||
#define FASTFETCH_DATATEXT_HELP_FORMAT "@DATATEXT_HELP_FORMAT@"
|
||||
|
||||
Reference in New Issue
Block a user