Fastfetch: print module description for --list-modules

This commit is contained in:
李通洲
2023-11-17 14:12:17 +08:00
parent ce6041938a
commit 730c0d1c92
61 changed files with 75 additions and 10 deletions
+9 -4
View File
@@ -5,7 +5,7 @@ if not test -x fastfetch
end
set -l whole_text (fastfetch --pipe --help)
set -l modules (fastfetch --list-modules autocompletion)
set modules_complex (fastfetch --list-modules autocompletion)
complete -c fastfetch -f
@@ -23,7 +23,7 @@ for line in (string match -- ' -*' $whole_text)
switch (string match -r -- $regexp $args)
case '<\?command>'
set -l temp (string lower $modules)
set -l temp (string match -r "\\w+" $modules_complex | string lower)
set -l temp $temp-format"\tModule\\ format"
set res $res -x -a "color\tSupported\\ colors format\tCustom\\ format config\tConfiguration $temp"
case '<\?bool>'
@@ -38,8 +38,13 @@ for line in (string match -- ' -*' $whole_text)
case '<\?num>'
set res $res -x -a "0\tNumber 1\tNumber 2\tNumber 3\tNumber 4\tNumber 5\tNumber 6\tNumber 7\tNumber 8\tNumber 9\tNumber"
case '<structure>'
set temp $modules"\tModule"
set res $res -x -a "$temp"
function __fastfetch_complete_structure
for line in $modules_complex
set -l pair (string split -m 2 : $line)
echo -e "$pair[1]\t$pair[2]"
end
end
set res $res -x -a "(__fish_complete_list : __fastfetch_complete_structure)"
case '<logo>'
set -l temp (fastfetch --list-logos autocompletion)
set -l temp (string replace -- ' ' '\\ ' $temp)
+4 -4
View File
@@ -729,15 +729,15 @@
},
{
"const": "theme",
"description": "Print current theme information"
"description": "Print current theme of desktop environment"
},
{
"const": "uptime",
"description": "Print system uptime"
"description": "Print how long system has been running"
},
{
"const": "users",
"description": "List users currently logged in"
"description": "Print users currently logged in"
},
{
"const": "version",
@@ -844,7 +844,7 @@
"properties": {
"type": {
"const": "brightness",
"description": "Print current brightness / luminance of your monitors"
"description": "Print current brightness level of your monitors"
},
"ddcciSleep": {
"type": "integer",
+3
View File
@@ -10,6 +10,7 @@ struct yyjson_mut_val;
typedef struct FFModuleBaseInfo
{
const char* name;
const char* description;
// A dirty polymorphic implementation in C.
// This is UB, because `void*` is not compatible with `FF*Options*`.
// However we can't do it better unless we move to C++, so that `option` becomes a `this` pointer
@@ -25,6 +26,7 @@ typedef struct FFModuleBaseInfo
static inline void ffOptionInitModuleBaseInfo(
FFModuleBaseInfo* baseInfo,
const char* name,
const char* description,
void* parseCommandOptions, // bool (*const parseCommandOptions)(void* options, const char* key, const char* value)
void* parseJsonObject, // void (*const parseJsonObject)(void* options, yyjson_val *module)
void* printModule, // void (*const printModule)(void* options)
@@ -34,6 +36,7 @@ static inline void ffOptionInitModuleBaseInfo(
)
{
baseInfo->name = name;
baseInfo->description = description;
baseInfo->parseCommandOptions = (__typeof__(baseInfo->parseCommandOptions)) parseCommandOptions;
baseInfo->parseJsonObject = (__typeof__(baseInfo->parseJsonObject)) parseJsonObject;
baseInfo->printModule = (__typeof__(baseInfo->printModule)) printModule;
+2 -2
View File
@@ -192,9 +192,9 @@ static void listModules(bool pretty)
{
++count;
if (pretty)
printf("%d)%s%s\n", count, count > 9 ? " " : " ", (*modules)->name);
printf("%d)%s%-13s: %s\n", count, count > 9 ? " " : " ", (*modules)->name, (*modules)->description);
else
puts((*modules)->name);
printf("%s:%s\n", (*modules)->name, (*modules)->description);
}
}
}
+1
View File
@@ -246,6 +246,7 @@ void ffInitBatteryOptions(FFBatteryOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_BATTERY_MODULE_NAME,
"Print battery capacity, status, etc",
ffParseBatteryCommandOptions,
ffParseBatteryJsonObject,
ffPrintBattery,
+1
View File
@@ -165,6 +165,7 @@ void ffInitBiosOptions(FFBiosOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_BIOS_MODULE_NAME,
"Print BIOS name, version, release date, etc",
ffParseBiosCommandOptions,
ffParseBiosJsonObject,
ffPrintBios,
+1
View File
@@ -171,6 +171,7 @@ void ffInitBluetoothOptions(FFBluetoothOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_BLUETOOTH_MODULE_NAME,
"List bluetooth devices",
ffParseBluetoothCommandOptions,
ffParseBluetoothJsonObject,
ffPrintBluetooth,
+1
View File
@@ -130,6 +130,7 @@ void ffInitBoardOptions(FFBoardOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_BOARD_MODULE_NAME,
"Print mather board name and other info",
ffParseBoardCommandOptions,
ffParseBoardJsonObject,
ffPrintBoard,
+1
View File
@@ -21,6 +21,7 @@ void ffInitBreakOptions(FF_MAYBE_UNUSED FFBreakOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_BREAK_MODULE_NAME,
"Print a empty line",
ffParseBreakCommandOptions,
ffParseBreakJsonObject,
ffPrintBreak,
+1
View File
@@ -186,6 +186,7 @@ void ffInitBrightnessOptions(FFBrightnessOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_BRIGHTNESS_MODULE_NAME,
"Print current brightness level of your monitors",
ffParseBrightnessCommandOptions,
ffParseBrightnessJsonObject,
ffPrintBrightness,
+1
View File
@@ -152,6 +152,7 @@ void ffInitChassisOptions(FFChassisOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_CHASSIS_MODULE_NAME,
"Print chassis type (desktop, laptop, etc)",
ffParseChassisCommandOptions,
ffParseChassisJsonObject,
ffPrintChassis,
+1
View File
@@ -156,6 +156,7 @@ void ffInitColorsOptions(FFColorsOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_COLORS_MODULE_NAME,
"Print some colored blocks",
ffParseColorsCommandOptions,
ffParseColorsJsonObject,
ffPrintColors,
+1
View File
@@ -151,6 +151,7 @@ void ffInitCommandOptions(FFCommandOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_COMMAND_MODULE_NAME,
"Running custom shell scripts",
ffParseCommandCommandOptions,
ffParseCommandJsonObject,
ffPrintCommand,
+1
View File
@@ -202,6 +202,7 @@ void ffInitCPUOptions(FFCPUOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_CPU_MODULE_NAME,
"Print CPU name, frequency, etc",
ffParseCPUCPUOptions,
ffParseCPUJsonObject,
ffPrintCPU,
+1
View File
@@ -172,6 +172,7 @@ void ffInitCPUUsageOptions(FFCPUUsageOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_CPUUSAGE_MODULE_NAME,
"Print CPU usage. Costs some time to collect data",
ffParseCPUUsageCommandOptions,
ffParseCPUUsageJsonObject,
ffPrintCPUUsage,
+1
View File
@@ -122,6 +122,7 @@ void ffInitCursorOptions(FFCursorOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_CURSOR_MODULE_NAME,
"Print cursor style name",
ffParseCursorCommandOptions,
ffParseCursorJsonObject,
ffPrintCursor,
+1
View File
@@ -57,6 +57,7 @@ void ffInitCustomOptions(FFCustomOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_CUSTOM_MODULE_NAME,
"Print a custom string, with or without key",
ffParseCustomCommandOptions,
ffParseCustomJsonObject,
ffPrintCustom,
+1
View File
@@ -214,6 +214,7 @@ void ffInitDateTimeOptions(FFDateTimeOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_DATETIME_MODULE_NAME,
"Print current date and time",
ffParseDateTimeCommandOptions,
ffParseDateTimeJsonObject,
ffPrintDateTime,
+1
View File
@@ -127,6 +127,7 @@ void ffInitDEOptions(FFDEOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_DE_MODULE_NAME,
"Print desktop environment name",
ffParseDECommandOptions,
ffParseDEJsonObject,
ffPrintDE,
+1
View File
@@ -463,6 +463,7 @@ void ffInitDiskOptions(FFDiskOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_DISK_MODULE_NAME,
"Print partitions, space usage, disk type, etc",
ffParseDiskCommandOptions,
ffParseDiskJsonObject,
ffPrintDisk,
+1
View File
@@ -229,6 +229,7 @@ void ffInitDiskIOOptions(FFDiskIOOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_DISKIO_MODULE_NAME,
"Print physical disk I/O throughput",
ffParseDiskIOCommandOptions,
ffParseDiskIOJsonObject,
ffPrintDiskIO,
+1
View File
@@ -258,6 +258,7 @@ void ffInitDisplayOptions(FFDisplayOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_DISPLAY_MODULE_NAME,
"Print resolutions, refresh rates, etc",
ffParseDisplayCommandOptions,
ffParseDisplayJsonObject,
ffPrintDisplay,
+1
View File
@@ -120,6 +120,7 @@ void ffInitFontOptions(FFFontOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_FONT_MODULE_NAME,
"Print system font name",
ffParseFontCommandOptions,
ffParseFontJsonObject,
ffPrintFont,
+1
View File
@@ -130,6 +130,7 @@ void ffInitGamepadOptions(FFGamepadOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_GAMEPAD_MODULE_NAME,
"List connected gamepads",
ffParseGamepadCommandOptions,
ffParseGamepadJsonObject,
ffPrintGamepad,
+1
View File
@@ -336,6 +336,7 @@ void ffInitGPUOptions(FFGPUOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_GPU_MODULE_NAME,
"Print GPU names, graphic memory size, type, etc",
ffParseGPUCommandOptions,
ffParseGPUJsonObject,
ffPrintGPU,
+1
View File
@@ -151,6 +151,7 @@ void ffInitHostOptions(FFHostOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_HOST_MODULE_NAME,
"Print product name of your computer",
ffParseHostCommandOptions,
ffParseHostJsonObject,
ffPrintHost,
+1
View File
@@ -91,6 +91,7 @@ void ffInitIconsOptions(FFIconsOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_ICONS_MODULE_NAME,
"Print icon style name",
ffParseIconsCommandOptions,
ffParseIconsJsonObject,
ffPrintIcons,
+1
View File
@@ -89,6 +89,7 @@ void ffInitKernelOptions(FFKernelOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_KERNEL_MODULE_NAME,
"Print system kernel version",
ffParseKernelCommandOptions,
ffParseKernelJsonObject,
ffPrintKernel,
+1
View File
@@ -129,6 +129,7 @@ void ffInitLMOptions(FFLMOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_LM_MODULE_NAME,
"Print login manager (desktop manager) name and version",
ffParseLMCommandOptions,
ffParseLMJsonObject,
ffPrintLM,
+1
View File
@@ -91,6 +91,7 @@ void ffInitLocaleOptions(FFLocaleOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_LOCALE_MODULE_NAME,
"Print system locale name",
ffParseLocaleCommandOptions,
ffParseLocaleJsonObject,
ffPrintLocale,
+1
View File
@@ -359,6 +359,7 @@ void ffInitLocalIpOptions(FFLocalIpOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_LOCALIP_MODULE_NAME,
"List local IP addresses (v4 or v6), MAC addresses, etc",
ffParseLocalIpCommandOptions,
ffParseLocalIpJsonObject,
ffPrintLocalIp,
+1
View File
@@ -173,6 +173,7 @@ void ffInitMediaOptions(FFMediaOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_MEDIA_MODULE_NAME,
"Print playing song name",
ffParseMediaCommandOptions,
ffParseMediaJsonObject,
ffPrintMedia,
+1
View File
@@ -131,6 +131,7 @@ void ffInitMemoryOptions(FFMemoryOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_MEMORY_MODULE_NAME,
"Print system memory usage info",
ffParseMemoryCommandOptions,
ffParseMemoryJsonObject,
ffPrintMemory,
+1
View File
@@ -163,6 +163,7 @@ void ffInitMonitorOptions(FFMonitorOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_MONITOR_MODULE_NAME,
"Print connected physical monitor information",
ffParseMonitorCommandOptions,
ffParseMonitorJsonObject,
ffPrintMonitor,
+1
View File
@@ -220,6 +220,7 @@ void ffInitNetIOOptions(FFNetIOOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_NETIO_MODULE_NAME,
"Print network I/O throughput",
ffParseNetIOCommandOptions,
ffParseNetIOJsonObject,
ffPrintNetIO,
+1
View File
@@ -114,6 +114,7 @@ void ffInitOpenCLOptions(FFOpenCLOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_OPENCL_MODULE_NAME,
"Print highest OpenCL version supported by the GPU",
ffParseOpenCLCommandOptions,
ffParseOpenCLJsonObject,
ffPrintOpenCL,
+1
View File
@@ -173,6 +173,7 @@ void ffInitOpenGLOptions(FFOpenGLOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_OPENGL_MODULE_NAME,
"Print highest OpenGL version supported by the GPU",
ffParseOpenGLCommandOptions,
ffParseOpenGLJsonObject,
ffPrintOpenGL,
+1
View File
@@ -217,6 +217,7 @@ void ffInitOSOptions(FFOSOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_OS_MODULE_NAME,
"Print operating system name and version",
ffParseOSCommandOptions,
ffParseOSJsonObject,
ffPrintOS,
+1
View File
@@ -238,6 +238,7 @@ void ffInitPackagesOptions(FFPackagesOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_PACKAGES_MODULE_NAME,
"List installed package managers and count of installed packages",
ffParsePackagesCommandOptions,
ffParsePackagesJsonObject,
ffPrintPackages,
+1
View File
@@ -139,6 +139,7 @@ void ffInitPlayerOptions(FFPlayerOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_PLAYER_MODULE_NAME,
"Print music player name",
ffParsePlayerCommandOptions,
ffParsePlayerJsonObject,
ffPrintPlayer,
+1
View File
@@ -140,6 +140,7 @@ void ffInitPowerAdapterOptions(FFPowerAdapterOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_POWERADAPTER_MODULE_NAME,
"Print power adapter name and charging watts",
ffParsePowerAdapterCommandOptions,
ffParsePowerAdapterJsonObject,
ffPrintPowerAdapter,
+1
View File
@@ -92,6 +92,7 @@ void ffInitProcessesOptions(FFProcessesOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_PROCESSES_MODULE_NAME,
"Count running processes",
ffParseProcessesCommandOptions,
ffParseProcessesJsonObject,
ffPrintProcesses,
+1
View File
@@ -136,6 +136,7 @@ void ffInitPublicIpOptions(FFPublicIpOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_PUBLICIP_MODULE_NAME,
"Print your public IP address, etc",
ffParsePublicIpCommandOptions,
ffParsePublicIpJsonObject,
ffPrintPublicIp,
+1
View File
@@ -123,6 +123,7 @@ void ffInitSeparatorOptions(FFSeparatorOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_SEPARATOR_MODULE_NAME,
"Print a separator line",
ffParseSeparatorCommandOptions,
ffParseSeparatorJsonObject,
ffPrintSeparator,
+1
View File
@@ -112,6 +112,7 @@ void ffInitShellOptions(FFShellOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_SHELL_MODULE_NAME,
"Print current shell name and version",
ffParseShellCommandOptions,
ffParseShellJsonObject,
ffPrintShell,
+1
View File
@@ -215,6 +215,7 @@ void ffInitSoundOptions(FFSoundOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_SOUND_MODULE_NAME,
"Print sound devices, volume, etc",
ffParseSoundCommandOptions,
ffParseSoundJsonObject,
ffPrintSound,
+1
View File
@@ -138,6 +138,7 @@ void ffInitSwapOptions(FFSwapOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_SWAP_MODULE_NAME,
"Print swap (paging file) space usage",
ffParseSwapCommandOptions,
ffParseSwapJsonObject,
ffPrintSwap,
+1
View File
@@ -111,6 +111,7 @@ void ffInitTerminalOptions(FFTerminalOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_TERMINAL_MODULE_NAME,
"Print current terminal name and version",
ffParseTerminalCommandOptions,
ffParseTerminalJsonObject,
ffPrintTerminal,
+1
View File
@@ -136,6 +136,7 @@ void ffInitTerminalFontOptions(FFTerminalFontOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_TERMINALFONT_MODULE_NAME,
"Print font name and size used by current terminal",
ffParseTerminalFontCommandOptions,
ffParseTerminalFontJsonObject,
ffPrintTerminalFont,
+1
View File
@@ -106,6 +106,7 @@ void ffInitTerminalSizeOptions(FFTerminalSizeOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_TERMINALSIZE_MODULE_NAME,
"Print current terminal size",
ffParseTerminalSizeCommandOptions,
ffParseTerminalSizeJsonObject,
ffPrintTerminalSize,
+1
View File
@@ -91,6 +91,7 @@ void ffInitThemeOptions(FFThemeOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_THEME_MODULE_NAME,
"Print current theme of desktop environment",
ffParseThemeCommandOptions,
ffParseThemeJsonObject,
ffPrintTheme,
+1
View File
@@ -198,6 +198,7 @@ void ffInitTitleOptions(FFTitleOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_TITLE_MODULE_NAME,
"Print title, which contains your user name, hostname",
ffParseTitleCommandOptions,
ffParseTitleJsonObject,
ffPrintTitle,
+1
View File
@@ -155,6 +155,7 @@ void ffInitUptimeOptions(FFUptimeOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_UPTIME_MODULE_NAME,
"Print how long system has been running",
ffParseUptimeCommandOptions,
ffParseUptimeJsonObject,
ffPrintUptime,
+1
View File
@@ -192,6 +192,7 @@ void ffInitUsersOptions(FFUsersOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_USERS_MODULE_NAME,
"Print users currently logged in",
ffParseUsersCommandOptions,
ffParseUsersJsonObject,
ffPrintUsers,
+1
View File
@@ -132,6 +132,7 @@ void ffInitVersionOptions(FFVersionOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_VERSION_MODULE_NAME,
"Print Fastfetch version",
ffParseVersionCommandOptions,
ffParseVersionJsonObject,
ffPrintVersion,
+1
View File
@@ -148,6 +148,7 @@ void ffInitVulkanOptions(FFVulkanOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_VULKAN_MODULE_NAME,
"Print highest Vulkan version supported by the GPU",
ffParseVulkanCommandOptions,
ffParseVulkanJsonObject,
ffPrintVulkan,
+1
View File
@@ -101,6 +101,7 @@ void ffInitWallpaperOptions(FFWallpaperOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_WALLPAPER_MODULE_NAME,
"Print image file path of current wallpaper",
ffParseWallpaperCommandOptions,
ffParseWallpaperJsonObject,
ffPrintWallpaper,
+1
View File
@@ -137,6 +137,7 @@ void ffInitWeatherOptions(FFWeatherOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_WEATHER_MODULE_NAME,
"Print weather information",
ffParseWeatherCommandOptions,
ffParseWeatherJsonObject,
ffPrintWeather,
+1
View File
@@ -173,6 +173,7 @@ void ffInitWifiOptions(FFWifiOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_WIFI_MODULE_NAME,
"Print connected Wi-Fi info (SSID, connection and security protocol)",
ffParseWifiCommandOptions,
ffParseWifiJsonObject,
ffPrintWifi,
+1
View File
@@ -140,6 +140,7 @@ void ffInitWMOptions(FFWMOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_WM_MODULE_NAME,
"Print window manager name and version",
ffParseWMCommandOptions,
ffParseWMJsonObject,
ffPrintWM,
+1
View File
@@ -89,6 +89,7 @@ void ffInitWMThemeOptions(FFWMThemeOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_WMTHEME_MODULE_NAME,
"Print current theme of window manager",
ffParseWMThemeCommandOptions,
ffParseWMThemeJsonObject,
ffPrintWMTheme,