diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f743443e6..4a183d5f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -452,7 +452,7 @@ jobs: version: '7.5' run: | uname -a - sudo pkg_add -r cmake git pkgconf wayland vulkan-headers vulkan-loader glib2 dconf dbus sqlite3 xfconf imagemagick chafa pulseaudio py3-requests + sudo pkg_add -r cmake git pkgconf wayland vulkan-headers vulkan-loader glib2 dconf dbus sqlite3 xfconf imagemagick chafa pulseaudio hwdata py3-requests cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=ON . cmake --build . --target package --verbose -j4 ./fastfetch --list-features diff --git a/CHANGELOG.md b/CHANGELOG.md index c27b86326..07442efe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,33 @@ +# 2.32.0 + +Bugfixes: +* Fix `pci.ids` file location on OpenBSD (GPU, OpenBSD) + * It's normally unused because enumerating PCI devices on OpenBSD requires root privileges +* Fix bssid formatting (Wifi, Linux) +* Fix Linux Lite distro detection (#1434, OS, Linux) +* Suppress XE driver warnings from Mesa (#1435, OpenGL, Linux) +* Fix format parameter name (#1443, Version) +* Don't report useless information when Wifi is disabled (Wifi, FreeBSD) + * Currently there are issues when the SSID contains whitespaces. More fixes are expected in the future. +* Always use physical size reported by X11 server to avoid inconsistent results (#1444, Display, Linux) + +Features: +* Randomly select one if the logo source expands to multiple files (#1426, Logo) +* Report mac product name when running Linux in MacBook (Host, Linux / FreeBSD) +* Use screen size reported in DTD if make sense (Display) +* Detect Virtualized Apple Silicon CPUs (CPU, Linux) +* Add detection support for fvwm and ctwm (WM, OpenBSD / NetBSD) +* Add Armbian-unofficial detection (OS, Linux) +* Prefer surfaceless display when connect EGL (OpenGL) +* Improve accuracy of WM detection on FreeBSD (WM, FreeBSD) +* Add ratpoison window manager (WM, Linux) + +Logo: +* Update Linux Lite +* Add Serpent OS +* Add Ultramarine Small +* Update Debian + # 2.31.0 Bugfixes: diff --git a/CMakeLists.txt b/CMakeLists.txt index 12041866f..792379f38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url project(fastfetch - VERSION 2.31.0 + VERSION 2.32.0 LANGUAGES C DESCRIPTION "Fast neofetch-like system information tool" HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch" @@ -502,6 +502,7 @@ if(LINUX) src/detection/gpu/gpu_pci.c src/detection/gtk_qt/gtk.c src/detection/host/host_linux.c + src/detection/host/host_mac.c src/detection/icons/icons_linux.c src/detection/initsystem/initsystem_linux.c src/detection/keyboard/keyboard_linux.c @@ -649,6 +650,7 @@ elseif(FreeBSD) src/detection/gpu/gpu_pci.c src/detection/gtk_qt/gtk.c src/detection/host/host_bsd.c + src/detection/host/host_mac.c src/detection/lm/lm_linux.c src/detection/icons/icons_linux.c src/detection/initsystem/initsystem_linux.c @@ -881,6 +883,7 @@ elseif(APPLE) src/detection/gpu/gpu_apple.c src/detection/gpu/gpu_apple.m src/detection/host/host_apple.c + src/detection/host/host_mac.c src/detection/icons/icons_nosupport.c src/detection/initsystem/initsystem_linux.c src/detection/keyboard/keyboard_apple.c @@ -949,6 +952,7 @@ elseif(WIN32) src/detection/dns/dns_windows.c src/detection/font/font_windows.c src/detection/gpu/gpu_windows.c + src/detection/host/host_mac.c src/detection/host/host_windows.c src/detection/icons/icons_windows.c src/detection/initsystem/initsystem_nosupport.c diff --git a/debian/changelog b/debian/changelog index bf1ef555e..bb9875dd5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +fastfetch (2.31.0) jammy; urgency=medium + + * Update to 2.31.0 + + -- Carter Li Wed, 04 Dec 2024 08:41:40 +0800 + fastfetch (2.30.1) jammy; urgency=medium * Update to 2.30.1 diff --git a/debian/files b/debian/files index 6cd2ef9b5..d297f8aab 100644 --- a/debian/files +++ b/debian/files @@ -1 +1 @@ -fastfetch_2.30.1_source.buildinfo universe/utils optional +fastfetch_2.31.0_source.buildinfo universe/utils optional diff --git a/doc/json_schema.json b/doc/json_schema.json index 3c0c9fa76..efb530e7d 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -26,10 +26,6 @@ "description": "Set the icon to be displayed by `display.keyType: \"icon\"`", "type": "string" }, - "format": { - "description": "Output format of the module. See `-h -format` for detail. I.e: fastfetch -h disk-format", - "type": "string" - }, "outputColor": { "description": "Output color of the module. Left empty to use `display.color.output`", "$ref": "#/$defs/colors" @@ -111,6 +107,288 @@ } } ] + }, + + + "batteryFormat": { + "description": "Output format of the module `Battery`. See `-h format` for formatting syntax\n 1. {manufacturer}: Battery manufacturer\n 2. {model-name}: Battery model name\n 3. {technology}: Battery technology\n 4. {capacity}: Battery capacity (percentage num)\n 5. {status}: Battery status\n 6. {temperature}: Battery temperature (formatted)\n 7. {cycle-count}: Battery cycle count\n 8. {serial}: Battery serial number\n 9. {manufacture-date}: Battery manufactor date\n 10. {capacity-bar}: Battery capacity (percentage bar)\n 11. {time-days}: Battery time remaining days\n 12. {time-hours}: Battery time remaining hours\n 13. {time-minutes}: Battery time remaining minutes\n 14. {time-seconds}: Battery time remaining seconds", + "type": "string" + }, + "biosFormat": { + "description": "Output format of the module `Bios`. See `-h format` for formatting syntax\n 1. {date}: Bios date\n 2. {release}: Bios release\n 3. {vendor}: Bios vendor\n 4. {version}: Bios version\n 5. {type}: Firmware type", + "type": "string" + }, + "bluetoothFormat": { + "description": "Output format of the module `Bluetooth`. See `-h format` for formatting syntax\n 1. {name}: Name\n 2. {address}: Address\n 3. {type}: Type\n 4. {battery-percentage}: Battery percentage number\n 5. {connected}: Is connected\n 6. {battery-percentage-bar}: Battery percentage bar", + "type": "string" + }, + "bluetoothradioFormat": { + "description": "Output format of the module `BluetoothRadio`. See `-h format` for formatting syntax\n 1. {name}: Radio name for discovering\n 2. {address}: Address\n 3. {lmp-version}: LMP version\n 4. {lmp-subversion}: LMP subversion\n 5. {version}: Bluetooth version\n 6. {vendor}: Vendor\n 7. {discoverable}: Discoverable\n 8. {connectable}: Connectable / Pairable", + "type": "string" + }, + "boardFormat": { + "description": "Output format of the module `Board`. See `-h format` for formatting syntax\n 1. {name}: Board name\n 2. {vendor}: Board vendor\n 3. {version}: Board version\n 4. {serial}: Board serial number", + "type": "string" + }, + "bootmgrFormat": { + "description": "Output format of the module `Bootmgr`. See `-h format` for formatting syntax\n 1. {name}: Name / description\n 2. {firmware-path}: Firmware file path\n 3. {firmware-name}: Firmware file name\n 4. {secure-boot}: Is secure boot enabled", + "type": "string" + }, + "brightnessFormat": { + "description": "Output format of the module `Brightness`. See `-h format` for formatting syntax\n 1. {percentage}: Screen brightness (percentage num)\n 2. {name}: Screen name\n 3. {max}: Maximum brightness value\n 4. {min}: Minimum brightness value\n 5. {current}: Current brightness value\n 6. {percentage-bar}: Screen brightness (percentage bar)", + "type": "string" + }, + "btrfsFormat": { + "description": "Output format of the module `Btrfs`. See `-h format` for formatting syntax\n 1. {name}: Name / Label\n 2. {uuid}: UUID\n 3. {devices}: Associated devices\n 4. {features}: Enabled features\n 5. {used}: Size used\n 6. {allocated}: Size allocated\n 7. {total}: Size total\n 8. {used-percentage}: Used percentage num\n 9. {allocated-percentage}: Allocated percentage num\n 10. {used-percentage-bar}: Used percentage bar\n 11. {allocated-percentage-bar}: Allocated percentage bar\n 12. {node-size}: Node size\n 13. {sector-size}: Sector size", + "type": "string" + }, + "cameraFormat": { + "description": "Output format of the module `Camera`. See `-h format` for formatting syntax\n 1. {name}: Device name\n 2. {vendor}: Vendor\n 3. {colorspace}: Color space\n 4. {id}: Identifier\n 5. {width}: Width (in px)\n 6. {height}: Height (in px)", + "type": "string" + }, + "chassisFormat": { + "description": "Output format of the module `Chassis`. See `-h format` for formatting syntax\n 1. {type}: Chassis type\n 2. {vendor}: Chassis vendor\n 3. {version}: Chassis version\n 4. {serial}: Chassis serial number", + "type": "string" + }, + "commandFormat": { + "description": "Output format of the module `Command`. See `-h format` for formatting syntax\n 1. {result}: Command result", + "type": "string" + }, + "cpuFormat": { + "description": "Output format of the module `CPU`. See `-h format` for formatting syntax\n 1. {name}: Name\n 2. {vendor}: Vendor\n 3. {cores-physical}: Physical core count\n 4. {cores-logical}: Logical core count\n 5. {cores-online}: Online core count\n 6. {freq-base}: Base frequency (formatted)\n 7. {freq-max}: Max frequency (formatted)\n 8. {temperature}: Temperature (formatted)\n 9. {core-types}: Logical core count grouped by frequency\n 10. {packages}: Processor package count", + "type": "string" + }, + "cpucacheFormat": { + "description": "Output format of the module `CPUCache`. See `-h format` for formatting syntax\n 1. {result}: Separate result\n 2. {sum}: Sum result", + "type": "string" + }, + "cpuusageFormat": { + "description": "Output format of the module `CPUUsage`. See `-h format` for formatting syntax\n 1. {avg}: CPU usage (percentage num, average)\n 2. {max}: CPU usage (percentage num, maximum)\n 3. {max-index}: CPU core index of maximum usage\n 4. {min}: CPU usage (percentage num, minimum)\n 5. {min-index}: CPU core index of minimum usage\n 6. {avg-bar}: CPU usage (percentage bar, average)\n 7. {max-bar}: CPU usage (percentage bar, maximum)\n 8. {min-bar}: CPU usage (percentage bar, minimum)", + "type": "string" + }, + "cursorFormat": { + "description": "Output format of the module `Cursor`. See `-h format` for formatting syntax\n 1. {theme}: Cursor theme\n 2. {size}: Cursor size", + "type": "string" + }, + "datetimeFormat": { + "description": "Output format of the module `DateTime`. See `-h format` for formatting syntax\n 1. {year}: Year\n 2. {year-short}: Last two digits of year\n 3. {month}: Month\n 4. {month-pretty}: Month with leading zero\n 5. {month-name}: Month name\n 6. {month-name-short}: Month name short\n 7. {week}: Week number on year\n 8. {weekday}: Weekday\n 9. {weekday-short}: Weekday short\n 10. {day-in-year}: Day in year\n 11. {day-in-month}: Day in month\n 12. {day-in-week}: Day in week\n 13. {hour}: Hour\n 14. {hour-pretty}: Hour with leading zero\n 15. {hour-12}: Hour 12h format\n 16. {hour-12-pretty}: Hour 12h format with leading zero\n 17. {minute}: Minute\n 18. {minute-pretty}: Minute with leading zero\n 19. {second}: Second\n 20. {second-pretty}: Second with leading zero\n 21. {offset-from-utc}: Offset from UTC in the ISO 8601 format\n 22. {timezone-name}: Locale-dependent timezone name or abbreviation\n 23. {day-pretty}: Day in month with leading zero", + "type": "string" + }, + "deFormat": { + "description": "Output format of the module `DE`. See `-h format` for formatting syntax\n 1. {process-name}: DE process name\n 2. {pretty-name}: DE pretty name\n 3. {version}: DE version", + "type": "string" + }, + "displayFormat": { + "description": "Output format of the module `Display`. See `-h format` for formatting syntax\n 1. {width}: Screen configured width (in pixels)\n 2. {height}: Screen configured height (in pixels)\n 3. {refresh-rate}: Screen configured refresh rate (in Hz)\n 4. {scaled-width}: Screen scaled width (in pixels)\n 5. {scaled-height}: Screen scaled height (in pixels)\n 6. {name}: Screen name\n 7. {type}: Screen type (builtin, external or unknown)\n 8. {rotation}: Screen rotation (in degrees)\n 9. {is-primary}: True if being the primary screen\n 10. {physical-width}: Screen physical width (in millimeters)\n 11. {physical-height}: Screen physical height (in millimeters)\n 12. {inch}: Physical diagonal length in inches\n 13. {ppi}: Pixels per inch (PPI)\n 14. {bit-depth}: Bits per color channel\n 15. {hdr-enabled}: True if high dynamic range (HDR) mode is enabled\n 16. {manufacture-year}: Year of manufacturing\n 17. {manufacture-week}: Nth week of manufacturing in the year\n 18. {serial}: Serial number\n 19. {platform-api}: The platform API used when detecting the display\n 20. {hdr-compatible}: True if the display is HDR compatible\n 21. {scale-factor}: HiDPI scale factor\n 22. {preferred-width}: Screen preferred width (in pixels)\n 23. {preferred-height}: Screen preferred height (in pixels)\n 24. {preferred-refresh-rate}: Screen preferred refresh rate (in Hz)", + "type": "string" + }, + "diskFormat": { + "description": "Output format of the module `Disk`. See `-h format` for formatting syntax\n 1. {size-used}: Size used\n 2. {size-total}: Size total\n 3. {size-percentage}: Size percentage num\n 4. {files-used}: Files used\n 5. {files-total}: Files total\n 6. {files-percentage}: Files percentage num\n 7. {is-external}: True if external volume\n 8. {is-hidden}: True if hidden volume\n 9. {filesystem}: Filesystem\n 10. {name}: Label / name\n 11. {is-readonly}: True if read-only\n 12. {create-time}: Create time in local timezone\n 13. {size-percentage-bar}: Size percentage bar\n 14. {files-percentage-bar}: Files percentage bar\n 15. {(null)}: (null)", + "type": "string" + }, + "diskioFormat": { + "description": "Output format of the module `DiskIO`. See `-h format` for formatting syntax\n 1. {size-read}: Size of data read [per second] (formatted)\n 2. {size-written}: Size of data written [per second] (formatted)\n 3. {name}: Device name\n 4. {dev-path}: Device raw file path\n 5. {bytes-read}: Size of data read [per second] (in bytes)\n 6. {bytes-written}: Size of data written [per second] (in bytes)\n 7. {read-count}: Number of reads\n 8. {write-count}: Number of writes", + "type": "string" + }, + "dnsFormat": { + "description": "Output format of the module `DNS`. See `-h format` for formatting syntax\n 1. {result}: DNS result", + "type": "string" + }, + "editorFormat": { + "description": "Output format of the module `Editor`. See `-h format` for formatting syntax\n 1. {type}: Type (Visual / Editor)\n 2. {name}: Name\n 3. {exe-name}: Exe name of real path\n 4. {full-path}: Full path of real path\n 5. {version}: Version", + "type": "string" + }, + "fontFormat": { + "description": "Output format of the module `Font`. See `-h format` for formatting syntax\n 1. {font1}: Font 1\n 2. {font2}: Font 2\n 3. {font3}: Font 3\n 4. {font4}: Font 4\n 5. {combined}: Combined fonts for display", + "type": "string" + }, + "gamepadFormat": { + "description": "Output format of the module `Gamepad`. See `-h format` for formatting syntax\n 1. {name}: Name\n 2. {serial}: Serial number\n 3. {battery-percentage}: Battery percentage num\n 4. {battery-percentage-bar}: Battery percentage bar", + "type": "string" + }, + "gpuFormat": { + "description": "Output format of the module `GPU`. See `-h format` for formatting syntax\n 1. {vendor}: GPU vendor\n 2. {name}: GPU name\n 3. {driver}: GPU driver\n 4. {temperature}: GPU temperature\n 5. {core-count}: GPU core count\n 6. {type}: GPU type\n 7. {dedicated-total}: GPU total dedicated memory\n 8. {dedicated-used}: GPU used dedicated memory\n 9. {shared-total}: GPU total shared memory\n 10. {shared-used}: GPU used shared memory\n 11. {platform-api}: The platform API used when detecting the GPU\n 12. {frequency}: Current frequency in GHz\n 13. {index}: GPU vendor specific index", + "type": "string" + }, + "hostFormat": { + "description": "Output format of the module `Host`. See `-h format` for formatting syntax\n 1. {family}: Product family\n 2. {name}: Product name\n 3. {version}: Product version\n 4. {sku}: Product sku\n 5. {vendor}: Product vendor\n 6. {serial}: Product serial number\n 7. {uuid}: Product uuid", + "type": "string" + }, + "iconsFormat": { + "description": "Output format of the module `Icons`. See `-h format` for formatting syntax\n 1. {icons1}: Icons part 1\n 2. {icons2}: Icons part 2", + "type": "string" + }, + "initsystemFormat": { + "description": "Output format of the module `InitSystem`. See `-h format` for formatting syntax\n 1. {name}: Init system name\n 2. {exe}: Init system exe path\n 3. {version}: Init system version path\n 4. {pid}: Init system pid", + "type": "string" + }, + "kernelFormat": { + "description": "Output format of the module `Kernel`. See `-h format` for formatting syntax\n 1. {sysname}: Sysname\n 2. {release}: Release\n 3. {version}: Version\n 4. {arch}: Architecture\n 5. {display-version}: Display version\n 6. {page-size}: Page size", + "type": "string" + }, + "keyboardFormat": { + "description": "Output format of the module `Keyboard`. See `-h format` for formatting syntax\n 1. {name}: Name\n 2. {serial}: Serial number", + "type": "string" + }, + "lmFormat": { + "description": "Output format of the module `LM`. See `-h format` for formatting syntax\n 1. {service}: LM service\n 2. {type}: LM type\n 3. {version}: LM version", + "type": "string" + }, + "loadavgFormat": { + "description": "Output format of the module `Loadavg`. See `-h format` for formatting syntax\n 1. {loadavg1}: Load average over 1min\n 2. {loadavg2}: Load average over 5min\n 3. {loadavg3}: Load average over 15min", + "type": "string" + }, + "localeFormat": { + "description": "Output format of the module `Locale`. See `-h format` for formatting syntax\n 1. {result}: Locale code", + "type": "string" + }, + "localipFormat": { + "description": "Output format of the module `LocalIp`. See `-h format` for formatting syntax\n 1. {ipv4}: IPv4 address\n 2. {ipv6}: IPv6 address\n 3. {mac}: MAC address\n 4. {ifname}: Interface name\n 5. {is-default-route}: Is default route\n 6. {mtu}: MTU size in bytes\n 7. {speed}: Link speed (formatted)\n 8. {flags}: Interface flags", + "type": "string" + }, + "mediaFormat": { + "description": "Output format of the module `Media`. See `-h format` for formatting syntax\n 1. {combined}: Pretty media name\n 2. {title}: Media name\n 3. {artist}: Artist name\n 4. {album}: Album name\n 5. {status}: Status", + "type": "string" + }, + "memoryFormat": { + "description": "Output format of the module `Memory`. See `-h format` for formatting syntax\n 1. {used}: Used size\n 2. {total}: Total size\n 3. {percentage}: Percentage used (num)\n 4. {percentage-bar}: Percentage used (bar)", + "type": "string" + }, + "monitorFormat": { + "description": "Output format of the module `Monitor`. See `-h format` for formatting syntax\n 1. {name}: Display name\n 2. {width}: Native resolution width in pixels\n 3. {height}: Native resolution height in pixels\n 4. {physical-width}: Physical width in millimeters\n 5. {physical-height}: Physical height in millimeters\n 6. {inch}: Physical diagonal length in inches\n 7. {ppi}: Pixels per inch (PPI)\n 8. {manufacture-year}: Year of manufacturing\n 9. {manufacture-week}: Nth week of manufacturing in the year\n 10. {serial}: Serial number\n 11. {refresh-rate}: Maximum refresh rate in Hz\n 12. {hdr-compatible}: True if the display is HDR compatible", + "type": "string" + }, + "mouseFormat": { + "description": "Output format of the module `Mouse`. See `-h format` for formatting syntax\n 1. {name}: Mouse name\n 2. {serial}: Mouse serial number", + "type": "string" + }, + "netioFormat": { + "description": "Output format of the module `NetIO`. See `-h format` for formatting syntax\n 1. {rx-size}: Size of data received [per second] (formatted)\n 2. {tx-size}: Size of data sent [per second] (formatted)\n 3. {ifname}: Interface name\n 4. {is-default-route}: Is default route\n 5. {rx-bytes}: Size of data received [per second] (in bytes)\n 6. {tx-bytes}: Size of data sent [per second] (in bytes)\n 7. {rx-packets}: Number of packets received [per second]\n 8. {tx-packets}: Number of packets sent [per second]\n 9. {rx-errors}: Number of errors received [per second]\n 10. {tx-errors}: Number of errors sent [per second]\n 11. {rx-drops}: Number of packets dropped when receiving [per second]\n 12. {tx-drops}: Number of packets dropped when sending [per second]", + "type": "string" + }, + "openclFormat": { + "description": "Output format of the module `OpenCL`. See `-h format` for formatting syntax\n 1. {version}: Platform version\n 2. {name}: Platform name\n 3. {vendor}: Platform vendor", + "type": "string" + }, + "openglFormat": { + "description": "Output format of the module `OpenGL`. See `-h format` for formatting syntax\n 1. {version}: OpenGL version\n 2. {renderer}: OpenGL renderer\n 3. {vendor}: OpenGL vendor\n 4. {slv}: OpenGL shading language version\n 5. {library}: OpenGL library used", + "type": "string" + }, + "osFormat": { + "description": "Output format of the module `OS`. See `-h format` for formatting syntax\n 1. {sysname}: Name of the kernel\n 2. {name}: Name of the OS\n 3. {pretty-name}: Pretty name of the OS\n 4. {id}: ID of the OS\n 5. {id-like}: ID like of the OS\n 6. {variant}: Variant of the OS\n 7. {variant-id}: Variant ID of the OS\n 8. {version}: Version of the OS\n 9. {version-id}: Version ID of the OS\n 10. {codename}: Version codename of the OS\n 11. {build-id}: Build ID of the OS\n 12. {arch}: Architecture of the OS", + "type": "string" + }, + "packagesFormat": { + "description": "Output format of the module `Packages`. See `-h format` for formatting syntax\n 1. {all}: Number of all packages\n 2. {pacman}: Number of pacman packages\n 3. {pacman-branch}: Pacman branch on manjaro\n 4. {dpkg}: Number of dpkg packages\n 5. {rpm}: Number of rpm packages\n 6. {emerge}: Number of emerge packages\n 7. {eopkg}: Number of eopkg packages\n 8. {xbps}: Number of xbps packages\n 9. {nix-system}: Number of nix-system packages\n 10. {nix-user}: Number of nix-user packages\n 11. {nix-default}: Number of nix-default packages\n 12. {apk}: Number of apk packages\n 13. {pkg}: Number of pkg packages\n 14. {flatpak-system}: Number of flatpak-system app packages\n 15. {flatpak-user}: Number of flatpak-user app packages\n 16. {snap}: Number of snap packages\n 17. {brew}: Number of brew packages\n 18. {brew-cask}: Number of brew-cask packages\n 19. {macports}: Number of macports packages\n 20. {scoop}: Number of scoop packages\n 21. {choco}: Number of choco packages\n 22. {pkgtool}: Number of pkgtool packages\n 23. {paludis}: Number of paludis packages\n 24. {winget}: Number of winget packages\n 25. {opkg}: Number of opkg packages\n 26. {am}: Number of am packages\n 27. {sorcery}: Number of sorcery packages\n 28. {lpkg}: Number of lpkg packages\n 29. {lpkgbuild}: Number of lpkgbuild packages\n 30. {guix-system}: Number of guix-system packages\n 31. {guix-user}: Number of guix-user packages\n 32. {guix-home}: Number of guix-home packages\n 33. {linglong}: Number of linglong packages\n 34. {pacstall}: Number of pacstall packages\n 35. {mport}: Number of mport packages\n 36. {qi}: Number of qi packages\n 37. {nix-all}: Total number of all nix packages\n 38. {flatpak-all}: Total number of all flatpak app packages\n 39. {brew-all}: Total number of all brew packages\n 40. {guix-all}: Total number of all guix packages", + "type": "string" + }, + "physicaldiskFormat": { + "description": "Output format of the module `PhysicalDisk`. See `-h format` for formatting syntax\n 1. {size}: Device size (formatted)\n 2. {name}: Device name\n 3. {interconnect}: Device interconnect type\n 4. {dev-path}: Device raw file path\n 5. {serial}: Serial number\n 6. {physical-type}: Device kind (SSD or HDD)\n 7. {removable-type}: Device kind (Removable or Fixed)\n 8. {readonly-type}: Device kind (Read-only or Read-write)\n 9. {revision}: Product revision\n 10. {temperature}: Device temperature (formatted)", + "type": "string" + }, + "physicalmemoryFormat": { + "description": "Output format of the module `PhysicalMemory`. See `-h format` for formatting syntax\n 1. {bytes}: Size (in bytes)\n 2. {size}: Size formatted\n 3. {max-speed}: Max speed (in MT/s)\n 4. {running-speed}: Running speed (in MT/s)\n 5. {type}: Type (DDR4, DDR5, etc.)\n 6. {form-factor}: Form factor (SODIMM, DIMM, etc.)\n 7. {locator}: Bank/Device Locator (BANK0/SIMM0, BANK0/SIMM1, etc.)\n 8. {vendor}: Vendor\n 9. {serial}: Serial number\n 10. {part-number}: Part number\n 11. {is-ecc-enabled}: True if ECC enabled", + "type": "string" + }, + "playerFormat": { + "description": "Output format of the module `Player`. See `-h format` for formatting syntax\n 1. {player}: Pretty player name\n 2. {name}: Player name\n 3. {id}: Player Identifier\n 4. {url}: URL name", + "type": "string" + }, + "poweradapterFormat": { + "description": "Output format of the module `PowerAdapter`. See `-h format` for formatting syntax\n 1. {watts}: Power adapter watts\n 2. {name}: Power adapter name\n 3. {manufacturer}: Power adapter manufacturer\n 4. {model}: Power adapter model\n 5. {description}: Power adapter description\n 6. {serial}: Power adapter serial number", + "type": "string" + }, + "processesFormat": { + "description": "Output format of the module `Processes`. See `-h format` for formatting syntax\n 1. {result}: Process count", + "type": "string" + }, + "publicipFormat": { + "description": "Output format of the module `PublicIp`. See `-h format` for formatting syntax\n 1. {ip}: Public IP address\n 2. {location}: Location", + "type": "string" + }, + "separatorFormat": { + "description": "Output format of the module `Separator`. See `-h format` for formatting syntax\n 1. {string}: Separator string\n 2. {outputColor}: Output color\n 3. {length}: Length", + "type": "string" + }, + "shellFormat": { + "description": "Output format of the module `Shell`. See `-h format` for formatting syntax\n 1. {process-name}: Shell process name\n 2. {exe}: The first argument of the command line when running the shell\n 3. {exe-name}: Shell base name of arg0\n 4. {version}: Shell version\n 5. {pid}: Shell pid\n 6. {pretty-name}: Shell pretty name\n 7. {exe-path}: Shell full exe path\n 8. {tty}: Shell tty used", + "type": "string" + }, + "soundFormat": { + "description": "Output format of the module `Sound`. See `-h format` for formatting syntax\n 1. {is-main}: Is main sound device\n 2. {name}: Device name\n 3. {volume-percentage}: Volume (in percentage num)\n 4. {identifier}: Identifier\n 5. {volume-percentage-bar}: Volume (in percentage bar)", + "type": "string" + }, + "swapFormat": { + "description": "Output format of the module `Swap`. See `-h format` for formatting syntax\n 1. {used}: Used size\n 2. {total}: Total size\n 3. {percentage}: Percentage used (num)\n 4. {percentage-bar}: Percentage used (bar)", + "type": "string" + }, + "terminalFormat": { + "description": "Output format of the module `Terminal`. See `-h format` for formatting syntax\n 1. {process-name}: Terminal process name\n 2. {exe}: The first argument of the command line when running the terminal\n 3. {exe-name}: Terminal base name of arg0\n 4. {pid}: Terminal pid\n 5. {pretty-name}: Terminal pretty name\n 6. {version}: Terminal version\n 7. {exe-path}: Terminal full exe path\n 8. {tty}: Terminal tty / pts used", + "type": "string" + }, + "terminalfontFormat": { + "description": "Output format of the module `TerminalFont`. See `-h format` for formatting syntax\n 1. {combined}: Terminal font combined\n 2. {name}: Terminal font name\n 3. {size}: Terminal font size\n 4. {styles}: Terminal font styles", + "type": "string" + }, + "terminalsizeFormat": { + "description": "Output format of the module `TerminalSize`. See `-h format` for formatting syntax\n 1. {rows}: Terminal rows\n 2. {columns}: Terminal columns\n 3. {width}: Terminal width (in pixels)\n 4. {height}: Terminal height (in pixels)", + "type": "string" + }, + "terminalthemeFormat": { + "description": "Output format of the module `TerminalTheme`. See `-h format` for formatting syntax\n 1. {fg-color}: Terminal foreground color\n 2. {fg-type}: Terminal foreground type (Dark / Light)\n 3. {bg-color}: Terminal background color\n 4. {bg-type}: Terminal background type (Dark / Light)", + "type": "string" + }, + "titleFormat": { + "description": "Output format of the module `Title`. See `-h format` for formatting syntax\n 1. {user-name}: User name\n 2. {host-name}: Host name\n 3. {home-dir}: Home directory\n 4. {exe-path}: Executable path of current process\n 5. {user-shell}: User's default shell\n 6. {user-name-colored}: User name (colored)\n 7. {at-symbol-colored}: @ symbol (colored)\n 8. {host-name-colored}: Host name (colored)", + "type": "string" + }, + "themeFormat": { + "description": "Output format of the module `Theme`. See `-h format` for formatting syntax\n 1. {theme1}: Theme part 1\n 2. {theme2}: Theme part 2", + "type": "string" + }, + "tpmFormat": { + "description": "Output format of the module `TPM`. See `-h format` for formatting syntax\n 1. {version}: TPM device version\n 2. {description}: TPM general description", + "type": "string" + }, + "uptimeFormat": { + "description": "Output format of the module `Uptime`. See `-h format` for formatting syntax\n 1. {days}: Days\n 2. {hours}: Hours\n 3. {minutes}: Minutes\n 4. {seconds}: Seconds\n 5. {milliseconds}: Milliseconds\n 6. {boot-time}: Boot time in local timezone", + "type": "string" + }, + "usersFormat": { + "description": "Output format of the module `Users`. See `-h format` for formatting syntax\n 1. {name}: User name\n 2. {host-name}: Host name\n 3. {session}: Session name\n 4. {client-ip}: Client IP\n 5. {login-time}: Login Time in local timezone", + "type": "string" + }, + "versionFormat": { + "description": "Output format of the module `Version`. See `-h format` for formatting syntax\n 1. {name}: Project name\n 2. {version}: Version\n 3. {version-tweak}: Version tweak\n 4. {build-type}: Build type (debug or release)\n 5. {sysname}: System name\n 6. {arch}: Architecture\n 7. {cmake-built-type}: CMake build type when compiling (Debug, Release, RelWithDebInfo, MinSizeRel)\n 8. {compile-time}: Date time when compiling\n 9. {compiler}: Compiler used when compiling\n 10. {libc}: Libc used when compiling", + "type": "string" + }, + "vulkanFormat": { + "description": "Output format of the module `Vulkan`. See `-h format` for formatting syntax\n 1. {driver}: Driver name\n 2. {api-version}: API version\n 3. {conformance-version}: Conformance version\n 4. {instance-version}: Instance version", + "type": "string" + }, + "wallpaperFormat": { + "description": "Output format of the module `Wallpaper`. See `-h format` for formatting syntax\n 1. {file-name}: File name\n 2. {full-path}: Full path", + "type": "string" + }, + "weatherFormat": { + "description": "Output format of the module `Weather`. See `-h format` for formatting syntax\n 1. {result}: Weather result", + "type": "string" + }, + "wmFormat": { + "description": "Output format of the module `WM`. See `-h format` for formatting syntax\n 1. {process-name}: WM process name\n 2. {pretty-name}: WM pretty name\n 3. {protocol-name}: WM protocol name\n 4. {plugin-name}: WM plugin name", + "type": "string" + }, + "wifiFormat": { + "description": "Output format of the module `Wifi`. See `-h format` for formatting syntax\n 1. {inf-desc}: Interface description\n 2. {inf-status}: Interface status\n 3. {status}: Connection status\n 4. {ssid}: Connection SSID\n 5. {bssid}: Connection BSSID\n 6. {protocol}: Connection protocol\n 7. {signal-quality}: Connection signal quality (percentage num)\n 8. {rx-rate}: Connection RX rate\n 9. {tx-rate}: Connection TX rate\n 10. {security}: Connection Security algorithm\n 11. {signal-quality-bar}: Connection signal quality (percentage bar)\n 12. {channel}: Connection channel number\n 13. {band}: Connection channel band in GHz", + "type": "string" + }, + "wmthemeFormat": { + "description": "Output format of the module `WMTheme`. See `-h format` for formatting syntax\n 1. {result}: WM theme", + "type": "string" + }, + "zpoolFormat": { + "description": "Output format of the module `Zpool`. See `-h format` for formatting syntax\n 1. {name}: Zpool name\n 2. {state}: Zpool state\n 3. {used}: Size used\n 4. {total}: Size total\n 5. {used-percentage}: Size percentage num\n 6. {fragmentation-percentage}: Fragmentation percentage num\n 7. {used-percentage-bar}: Size percentage bar\n 8. {fragmentation-percentage-bar}: Fragmentation percentage bar", + "type": "string" } }, "type": "object", @@ -771,158 +1049,24 @@ } }, { - "title": "module", - "description": "No additional properties", + "title": "Battery", "type": "object", "additionalProperties": false, "properties": { "type": { - "anyOf": [ - { - "const": "bios", - "description": "Print information of 1st-stage bootloader (name, version, release date, etc)" - }, - { - "const": "board", - "description": "Print motherboard name and other info" - }, - { - "const": "bootmgr", - "description": "Print information of 2nd-stage bootloader (name, firmware, etc)" - }, - { - "const": "camera", - "description": "Print available cameras" - }, - { - "const": "cpucache", - "description": "Print CPU cache sizes" - }, - { - "const": "cursor", - "description": "Print cursor style name" - }, - { - "const": "datetime", - "description": "Print current date and time" - }, - { - "const": "editor", - "description": "Print information of the default editor ($VISUAL or $EDITOR)" - }, - { - "const": "font", - "description": "Print system font name" - }, - { - "const": "host", - "description": "Print product name of your computer" - }, - { - "const": "icons", - "description": "Print icon style name" - }, - { - "const": "initsystem", - "description": "Print init system (pid 1) name and version" - }, - { - "const": "kernel", - "description": "Print system kernel version" - }, - { - "const": "lm", - "description": "Print login manager (desktop manager) name and version" - }, - { - "const": "locale", - "description": "Print system locale name" - }, - { - "const": "media", - "description": "Print playing song name" - }, - { - "const": "monitor", - "description": "Alias of Display module" - }, - { - "const": "opencl", - "description": "Print highest OpenCL version supported by the GPU" - }, - { - "const": "os", - "description": "Print operating system name and version" - }, - { - "const": "physicalmemory", - "description": "Print system physical memory devices" - }, - { - "const": "player", - "description": "Print music player name" - }, - { - "const": "poweradapter", - "description": "Print power adapter name and charging watts" - }, - { - "const": "processes", - "description": "Count running processes" - }, - { - "const": "shell", - "description": "Print current shell name and version" - }, - { - "const": "terminal", - "description": "Print current terminal name and version" - }, - { - "const": "terminalfont", - "description": "Print font name and size used by current terminal" - }, - { - "const": "terminalsize", - "description": "Print current terminal size" - }, - { - "const": "terminaltheme", - "description": "Print current terminal theme (foreground and background colors)" - }, - { - "const": "theme", - "description": "Print current theme of desktop environment" - }, - { - "const": "tpm", - "description": "Print info of Trusted Platform Module (TPM) Security Device" - }, - { - "const": "uptime", - "description": "Print how long system has been running" - }, - { - "const": "version", - "description": "Print Fastfetch version" - }, - { - "const": "vulkan", - "description": "Print highest Vulkan version supported by the GPU" - }, - { - "const": "wallpaper", - "description": "Print image file path of current wallpaper" - }, - { - "const": "wifi", - "description": "Print connected Wi-Fi info (SSID, connection and security protocol)" - }, - { - "const": "wmtheme", - "description": "Print current theme of window manager" - } - ] + "const": "battery", + "description": "Print battery capacity, status, etc" + }, + "useSetupApi": { + "description": "Set if `SetupAPI` should be used on Windows to detect battery info, which supports multi batteries, but slower. Windows only", + "type": "boolean", + "default": false + }, + "temp": { + "$ref": "#/$defs/temperature" + }, + "percent": { + "$ref": "#/$defs/percent" }, "key": { "$ref": "#/$defs/key" @@ -940,29 +1084,18 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/batteryFormat" } } }, { - "title": "Battery", + "title": "BIOS", "type": "object", "additionalProperties": false, "properties": { "type": { - "const": "battery", - "description": "Print battery capacity, status, etc" - }, - "useSetupApi": { - "description": "Set if `SetupAPI` should be used on Windows to detect battery info, which supports multi batteries, but slower. Windows only", - "type": "boolean", - "default": false - }, - "temp": { - "$ref": "#/$defs/temperature" - }, - "percent": { - "$ref": "#/$defs/percent" + "description": "Print information of 1st-stage bootloader (name, version, release date, etc)", + "const": "bios" }, "key": { "$ref": "#/$defs/key" @@ -980,7 +1113,7 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/biosFormat" } } }, @@ -1017,7 +1150,7 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/bluetoothFormat" } } }, @@ -1046,33 +1179,18 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/bluetoothradioFormat" } } }, { - "title": "Brightness", + "title": "Board", "type": "object", "additionalProperties": false, "properties": { "type": { - "const": "brightness", - "description": "Print current brightness level of your monitors" - }, - "percent": { - "$ref": "#/$defs/percent" - }, - "ddcciSleep": { - "type": "integer", - "description": "Set the sleep times (in ms) when sending DDC/CI requests.\nSee for detail", - "minimum": 0, - "maximum": 400, - "default": 10 - }, - "compact": { - "description": "Set if multiple results should be printed in one line", - "type": "boolean", - "default": false + "description": "Print motherboard name and other info", + "const": "board" }, "key": { "$ref": "#/$defs/key" @@ -1090,21 +1208,18 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/boardFormat" } } }, { - "title": "BTRFS", + "title": "Boot Manager", "type": "object", "additionalProperties": false, "properties": { "type": { - "const": "btrfs", - "description": "Print Btrfs volumes" - }, - "percent": { - "$ref": "#/$defs/percent" + "description": "Print information of 2nd-stage bootloader (name, firmware, etc)", + "const": "bootmgr" }, "key": { "$ref": "#/$defs/key" @@ -1122,18 +1237,33 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/bootmgrFormat" } } }, { - "title": "Chassis", + "title": "Brightness", "type": "object", "additionalProperties": false, "properties": { "type": { - "const": "chassis", - "description": "Print chassis type (desktop, laptop, etc)" + "const": "brightness", + "description": "Print current brightness level of your monitors" + }, + "percent": { + "$ref": "#/$defs/percent" + }, + "ddcciSleep": { + "type": "integer", + "description": "Set the sleep times (in ms) when sending DDC/CI requests.\nSee for detail", + "minimum": 0, + "maximum": 400, + "default": 10 + }, + "compact": { + "description": "Set if multiple results should be printed in one line", + "type": "boolean", + "default": false }, "key": { "$ref": "#/$defs/key" @@ -1151,20 +1281,110 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/brightnessFormat" } } }, { - "title": "CPU", + "title": "BTRFS", "type": "object", "additionalProperties": false, "properties": { "type": { - "description": "Print CPU name, frequency, etc", - "const": "cpu" + "const": "btrfs", + "description": "Print Linux BTRFS volumes" }, - "temp": { + "percent": { + "$ref": "#/$defs/percent" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/btrfsFormat" + } + } + }, + { + "title": "Camera", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "description": "Print available cameras", + "const": "camera" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/cameraFormat" + } + } + }, + { + "title": "Chassis", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "chassis", + "description": "Print chassis type (desktop, laptop, etc)" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/chassisFormat" + } + } + }, + { + "title": "CPU", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "description": "Print CPU name, frequency, etc", + "const": "cpu" + }, + "temp": { "$ref": "#/$defs/temperature" }, "showPeCoreCount": { @@ -1188,7 +1408,39 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/cpuFormat" + } + } + }, + { + "title": "CPU Cache", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "cpucache", + "description": "Print CPU cache sizes" + }, + "percent": { + "$ref": "#/$defs/percent" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/cpucacheFormat" } } }, @@ -1231,7 +1483,7 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/cpuusageFormat" } } }, @@ -1333,7 +1585,39 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/commandFormat" + } + } + }, + { + "title": "Cursor", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "cursor", + "description": "Print cursor style name" + }, + "percent": { + "$ref": "#/$defs/percent" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/cursorFormat" } } }, @@ -1368,6 +1652,38 @@ } } }, + { + "title": "Date Time", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "datetime", + "description": "Print current date and time" + }, + "percent": { + "$ref": "#/$defs/percent" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/datetimeFormat" + } + } + }, { "title": "Display", "type": "object", @@ -1418,7 +1734,7 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/displayFormat" } } }, @@ -1484,7 +1800,7 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/diskFormat" } } }, @@ -1528,12 +1844,12 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/diskioFormat" } } }, { - "title": "DE", + "title": "Desktop Environment", "type": "object", "additionalProperties": false, "properties": { @@ -1562,7 +1878,7 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/deFormat" } } }, @@ -1600,7 +1916,71 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/dnsFormat" + } + } + }, + { + "title": "Editor", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "editor", + "description": "Print information of the default editor ($VISUAL or $EDITOR)" + }, + "percent": { + "$ref": "#/$defs/percent" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/editorFormat" + } + } + }, + { + "title": "Font", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "font", + "description": "Print system font names" + }, + "percent": { + "$ref": "#/$defs/percent" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/fontFormat" } } }, @@ -1632,7 +2012,7 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/gamepadFormat" } } }, @@ -1690,43 +2070,188 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/gpuFormat" } } }, { - "title": "Local IP", + "title": "Host", "type": "object", "additionalProperties": false, "properties": { "type": { - "description": "List local IP addresses (v4 or v6), MAC addresses, etc", - "const": "localip" + "const": "host", + "description": "Print product name of your computer" }, - "showIpv4": { - "description": "Show IPv4 addresses", - "type": "boolean", - "default": true + "key": { + "$ref": "#/$defs/key" }, - "showIpv6": { - "description": "Show IPv6 addresses", - "type": "boolean", - "default": false + "keyColor": { + "$ref": "#/$defs/keyColor" }, - "showSpeed": { - "description": "Show ethernet rx speed", - "type": "boolean", - "default": false + "keyIcon": { + "$ref": "#/$defs/keyIcon" }, - "showMtu": { - "description": "Show MTU", - "type": "boolean", - "default": false + "keyWidth": { + "$ref": "#/$defs/keyWidth" }, - "showMac": { - "description": "Show MAC addresses", - "type": "boolean", - "default": false + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/hostFormat" + } + } + }, + { + "title": "Icons", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "icons", + "description": "Print icon style name" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/iconsFormat" + } + } + }, + { + "title": "Init System", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "initsystem", + "description": "Print init system (pid 1) name and version" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/initsystemFormat" + } + } + }, + { + "title": "Kernel", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "kernel", + "description": "Print system kernel version" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/kernelFormat" + } + } + }, + { + "title": "Login Manager", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "lm", + "description": "Print login manager (desktop manager) name and version" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/lmFormat" + } + } + }, + { + "title": "Local IP", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "description": "List local IP addresses (v4 or v6), MAC addresses, etc", + "const": "localip" + }, + "showIpv4": { + "description": "Show IPv4 addresses", + "type": "boolean", + "default": true + }, + "showIpv6": { + "description": "Show IPv6 addresses", + "type": "boolean", + "default": false + }, + "showSpeed": { + "description": "Show ethernet rx speed", + "type": "boolean", + "default": false + }, + "showMtu": { + "description": "Show MTU", + "type": "boolean", + "default": false + }, + "showMac": { + "description": "Show MAC addresses", + "type": "boolean", + "default": false }, "showLoop": { "description": "Show loop back addresses (127.0.0.1)", @@ -1778,18 +2303,30 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/localipFormat" } } }, { - "title": "Memory", + "title": "Loadavg", "type": "object", "additionalProperties": false, "properties": { "type": { - "const": "memory", - "description": "Print system memory usage info" + "const": "loadavg", + "description": "Print system load averages" + }, + "ndigits": { + "type": "integer", + "description": "Set the number of digits to keep after the decimal point", + "minimum": 0, + "maximum": 9, + "default": 2 + }, + "compact": { + "type": "boolean", + "description": "Show values in one line", + "default": true }, "percent": { "$ref": "#/$defs/percent" @@ -1810,30 +2347,76 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/loadavgFormat" } } }, { - "title": "Loadavg", + "title": "Locale", "type": "object", "additionalProperties": false, "properties": { "type": { - "const": "loadavg", - "description": "Print system load averages" + "const": "locale", + "description": "Print system locale name" }, - "ndigits": { - "type": "integer", - "description": "Set the number of digits to keep after the decimal point", - "minimum": 0, - "maximum": 9, - "default": 2 + "key": { + "$ref": "#/$defs/key" }, - "compact": { - "type": "boolean", - "description": "Show values in one line", - "default": true + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/localeFormat" + } + } + }, + { + "title": "Media", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "media", + "description": "Print song name of currently playing" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/mediaFormat" + } + } + }, + { + "title": "Memory", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "memory", + "description": "Print system memory usage info" }, "percent": { "$ref": "#/$defs/percent" @@ -1854,7 +2437,36 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/memoryFormat" + } + } + }, + { + "title": "Monitor", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "monitor", + "description": "Alias of Display module (for backwards compatibility, deprecated)" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/monitorFormat" } } }, @@ -1903,28 +2515,626 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/netioFormat" + } + } + }, + { + "title": "OpenCL", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "opencl", + "description": "Print highest OpenCL version supported by the GPU" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/openclFormat" + } + } + }, + { + "title": "OpenGL", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "description": "Print highest OpenGL version supported by the GPU", + "const": "opengl" + }, + "library": { + "description": "Set the OpenGL context creation library to use", + "enum": [ + "auto", + "egl", + "glx", + "osmesa" + ], + "default": "auto" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/openglFormat" + } + } + }, + { + "title": "Operating System", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "os", + "description": "Print OS / or Linux distro name and version" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/osFormat" + } + } + }, + { + "title": "Packages", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "packages", + "description": "List installed package managers and count of installed packages" + }, + "disabled": { + "description": "List of package managers to be disabled when detecting", + "type": "array", + "items": { + "type": "string", + "enum": [ + "am", + "apk", + "brew", + "choco", + "dpkg", + "emerge", + "eopkg", + "flatpak", + "guix", + "linglong", + "lpkg", + "lpkgbuild", + "macports", + "mport", + "nix", + "opkg", + "pacman", + "pacstall", + "paludis", + "pkg", + "pkgtool", + "qi", + "rpm", + "scoop", + "snap", + "sorcery", + "winget", + "xbps" + ], + "uniqueItems": true + }, + "default": ["winget"] + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/packagesFormat" + } + } + }, + { + "title": "Physical Disk", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "description": "Print physical disk information", + "const": "physicaldisk" + }, + "namePrefix": { + "description": "Show disks with given name prefix only", + "type": "string" + }, + "temp": { + "$ref": "#/$defs/temperature" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/physicaldiskFormat" + } + } + }, + { + "title": "Physical Memory", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "physicalmemory", + "description": "Print system physical memory devices" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/physicalmemoryFormat" + } + } + }, + { + "title": "Player", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "player", + "description": "Print music player name" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/playerFormat" + } + } + }, + { + "title": "Power Adapter", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "poweradapter", + "description": "Print power adapter name and charging watts" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/poweradapterFormat" + } + } + }, + { + "title": "Processes", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "processes", + "description": "Count running processes" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/processesFormat" + } + } + }, + { + "title": "Public IP", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "description": "Print your public IP address, etc", + "const": "publicip" + }, + "url": { + "description": "The URL of public IP detection server to be used. Only HTTP protocol is supported", + "type": "string", + "format": "url", + "default": "http://ipinfo.io/ip" + }, + "timeout": { + "description": "Time in milliseconds to wait for the public ip server to respond", + "type": "integer", + "minimum": 0, + "default": "disabled (0)" + }, + "ipv6": { + "description": "Whether to use IPv6 for public IP detection server", + "type": "boolean", + "default": false + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/publicipFormat" + } + } + }, + { + "title": "Separator", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "description": "Print a separator line", + "const": "separator" + }, + "string": { + "description": "Set the string to be printed by the separator line", + "type": "string", + "default": "-" + }, + "outputColor": { + "description": "Set the color of the separator line", + "$ref": "#/$defs/outputColor" + }, + "length": { + "description": "Set the length of the separator line, or 0 to auto-detect", + "type": "integer", + "minimum": 0, + "default": 0 + } + } + }, + { + "title": "Shell", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "shell", + "description": "Print current shell name and version" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/shellFormat" + } + } + }, + { + "title": "Sound", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "description": "Print sound devices, volume, etc", + "const": "sound" + }, + "soundType": { + "description": "Set what type of sound devices should be printed", + "type": "string", + "enum": [ + "main", + "active", + "all" + ], + "default": "main" + }, + "percent": { + "$ref": "#/$defs/percent" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/soundFormat" + } + } + }, + { + "title": "Swap", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "swap", + "description": "Print swap (paging file) space usage" + }, + "percent": { + "$ref": "#/$defs/percent" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/swapFormat" + } + } + }, + { + "title": "Terminal", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "terminal", + "description": "Print current terminal name and version" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/terminalFormat" + } + } + }, + { + "title": "Terminal Font", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "terminalfont", + "description": "Print font name and size used by current terminal" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/terminalfontFormat" + } + } + }, + { + "title": "Terminal Size", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "terminalsize", + "description": "Print current terminal size" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/terminalsizeFormat" + } + } + }, + { + "title": "Terminal Theme", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "terminaltheme", + "description": "Print current terminal theme (foreground and background colors)" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/terminalthemeFormat" } } }, { - "title": "OpenGL", + "title": "Theme", "type": "object", "additionalProperties": false, "properties": { "type": { - "description": "Print highest OpenGL version supported by the GPU", - "const": "opengl" - }, - "library": { - "description": "Set the OpenGL context creation library to use", - "enum": [ - "auto", - "egl", - "glx", - "osmesa" - ], - "default": "auto" + "const": "theme", + "description": "Print current theme of desktop environment" }, "key": { "$ref": "#/$defs/key" @@ -1942,57 +3152,42 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/themeFormat" } } }, { - "title": "Packages", + "title": "Title", "type": "object", "additionalProperties": false, "properties": { "type": { - "const": "packages", - "description": "List installed package managers and count of installed packages" + "description": "Print title, which contains your user name, hostname", + "const": "title" }, - "disabled": { - "description": "List of package managers to be disabled when detecting", - "type": "array", - "items": { - "type": "string", - "enum": [ - "am", - "apk", - "brew", - "choco", - "dpkg", - "emerge", - "eopkg", - "flatpak", - "guix", - "linglong", - "lpkg", - "lpkgbuild", - "macports", - "mport", - "nix", - "opkg", - "pacman", - "pacstall", - "paludis", - "pkg", - "pkgtool", - "qi", - "rpm", - "scoop", - "snap", - "sorcery", - "winget", - "xbps" - ], - "uniqueItems": true - }, - "default": ["winget"] + "fqdn": { + "type": "boolean", + "description": "Set if the title should use fully qualified domain name", + "default": false + }, + "color": { + "description": "Set colors of the different part of title", + "type": "object", + "additionalProperties": false, + "properties": { + "user": { + "description": "Set color of the user name (left part)", + "$ref": "#/$defs/colors" + }, + "at": { + "description": "Set color of the @ symbol (middle part)", + "$ref": "#/$defs/colors" + }, + "host": { + "description": "Set color of the host name (right part)", + "$ref": "#/$defs/colors" + } + } }, "key": { "$ref": "#/$defs/key" @@ -2010,25 +3205,18 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/titleFormat" } } }, { - "title": "Physical Disk", + "title": "TPM", "type": "object", "additionalProperties": false, "properties": { "type": { - "description": "Print physical disk information", - "const": "physicaldisk" - }, - "namePrefix": { - "description": "Show disks with given name prefix only", - "type": "string" - }, - "temp": { - "$ref": "#/$defs/temperature" + "const": "tpm", + "description": "Print info of Trusted Platform Module (TPM) Security Device" }, "key": { "$ref": "#/$defs/key" @@ -2046,34 +3234,27 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/tpmFormat" } } }, { - "title": "Public IP", + "title": "Users", "type": "object", "additionalProperties": false, "properties": { "type": { - "description": "Print your public IP address, etc", - "const": "publicip" - }, - "url": { - "description": "The URL of public IP detection server to be used. Only HTTP protocol is supported", - "type": "string", - "format": "url", - "default": "http://ipinfo.io/ip" + "const": "users", + "description": "Print users currently logged in" }, - "timeout": { - "description": "Time in milliseconds to wait for the public ip server to respond", - "type": "integer", - "minimum": 0, - "default": "disabled (0)" + "compact": { + "type": "boolean", + "description": "Show all active users in one line", + "default": false }, - "ipv6": { - "description": "Whether to use IPv6 for public IP detection server", + "myselfOnly": { "type": "boolean", + "description": "Show only the current user", "default": false }, "key": { @@ -2092,57 +3273,18 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" - } - } - }, - { - "title": "Separator", - "type": "object", - "additionalProperties": false, - "properties": { - "type": { - "description": "Print a separator line", - "const": "separator" - }, - "string": { - "description": "Set the string to be printed by the separator line", - "type": "string", - "default": "-" - }, - "outputColor": { - "description": "Set the color of the separator line", - "$ref": "#/$defs/outputColor" - }, - "length": { - "description": "Set the length of the separator line, or 0 to auto-detect", - "type": "integer", - "minimum": 0, - "default": 0 + "$ref": "#/$defs/usersFormat" } } }, { - "title": "Sound", + "title": "Uptime", "type": "object", "additionalProperties": false, "properties": { "type": { - "description": "Print sound devices, volume, etc", - "const": "sound" - }, - "soundType": { - "description": "Set what type of sound devices should be printed", - "type": "string", - "enum": [ - "main", - "active", - "all" - ], - "default": "main" - }, - "percent": { - "$ref": "#/$defs/percent" + "const": "uptime", + "description": "Print how long system has been running" }, "key": { "$ref": "#/$defs/key" @@ -2160,21 +3302,18 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/uptimeFormat" } } }, { - "title": "Swap", + "title": "Version", "type": "object", "additionalProperties": false, "properties": { "type": { - "const": "swap", - "description": "Print swap (paging file) space usage" - }, - "percent": { - "$ref": "#/$defs/percent" + "const": "version", + "description": "Print Fastfetch version" }, "key": { "$ref": "#/$defs/key" @@ -2192,42 +3331,18 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/versionFormat" } } }, { - "title": "Title", + "title": "Vulkan", "type": "object", "additionalProperties": false, "properties": { "type": { - "description": "Print title, which contains your user name, hostname", - "const": "title" - }, - "fqdn": { - "type": "boolean", - "description": "Set if the title should use fully qualified domain name", - "default": false - }, - "color": { - "description": "Set colors of the different part of title", - "type": "object", - "additionalProperties": false, - "properties": { - "user": { - "description": "Set color of the user name (left part)", - "$ref": "#/$defs/colors" - }, - "at": { - "description": "Set color of the @ symbol (middle part)", - "$ref": "#/$defs/colors" - }, - "host": { - "description": "Set color of the host name (right part)", - "$ref": "#/$defs/colors" - } - } + "const": "vulkan", + "description": "Print highest Vulkan version supported by the GPU" }, "key": { "$ref": "#/$defs/key" @@ -2245,28 +3360,18 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/vulkanFormat" } } }, { - "title": "Users", + "title": "Wallpaper", "type": "object", "additionalProperties": false, "properties": { "type": { - "const": "users", - "description": "Print users currently logged in" - }, - "compact": { - "type": "boolean", - "description": "Show all active users in one line", - "default": false - }, - "myselfOnly": { - "type": "boolean", - "description": "Show only the current user", - "default": false + "const": "wallpaper", + "description": "Print image file path of current wallpaper" }, "key": { "$ref": "#/$defs/key" @@ -2284,7 +3389,7 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/wallpaperFormat" } } }, @@ -2328,12 +3433,41 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/weatherFormat" + } + } + }, + { + "title": "Wi-Fi", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "wifi", + "description": "Print connected Wi-Fi info (SSID, connection and security protocol)" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/wifiFormat" } } }, { - "title": "WM", + "title": "Window Manager", "type": "object", "additionalProperties": false, "properties": { @@ -2362,7 +3496,36 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/wmFormat" + } + } + }, + { + "title": "WM Theme", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "const": "wmtheme", + "description": "Print current theme of window manager" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "keyIcon": { + "$ref": "#/$defs/keyIcon" + }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, + "outputColor": { + "$ref": "#/$defs/outputColor" + }, + "format": { + "$ref": "#/$defs/wmthemeFormat" } } }, @@ -2394,7 +3557,7 @@ "$ref": "#/$defs/outputColor" }, "format": { - "$ref": "#/$defs/format" + "$ref": "#/$defs/zpoolFormat" } } } diff --git a/scripts/gen-man.py b/scripts/gen-man.py index 2bb589add..14d725cfd 100755 --- a/scripts/gen-man.py +++ b/scripts/gen-man.py @@ -54,7 +54,7 @@ Parsing is not case sensitive. E.g. \fB--logo-type\fR is equal to \fB--LOGO-TYPE\fR. -If a value is between square brakets, it is optional. +If a value is between square brackets, it is optional. An optional boolean value defaults to true if not specified. More detailed help messages for each options can be printed diff --git a/src/common/format.h b/src/common/format.h index fa092b40a..d4ded993b 100644 --- a/src/common/format.h +++ b/src/common/format.h @@ -42,7 +42,5 @@ typedef struct FFformatarg void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg); void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t numArgs, const FFformatarg* arguments); -#define FF_PARSE_FORMAT_STRING_CHECKED(buffer, formatstr, numArgs, arguments) do {\ - static_assert(sizeof(arguments) / sizeof(*arguments) == (numArgs), "Invalid number of format arguments");\ - ffParseFormatString((buffer), (formatstr), (numArgs), (arguments));\ -} while (0) +#define FF_PARSE_FORMAT_STRING_CHECKED(buffer, formatstr, arguments) \ + ffParseFormatString((buffer), (formatstr), sizeof(arguments) / sizeof(*arguments), (arguments)); diff --git a/src/common/io/io_unix.c b/src/common/io/io_unix.c index 4cb946d0e..69b6fbca6 100644 --- a/src/common/io/io_unix.c +++ b/src/common/io/io_unix.c @@ -1,6 +1,7 @@ #include "io.h" #include "fastfetch.h" #include "util/stringUtils.h" +#include "common/time.h" #include #include @@ -145,10 +146,10 @@ bool ffPathExpandEnv(FF_MAYBE_UNUSED const char* in, FF_MAYBE_UNUSED FFstrbuf* o if (wordexp(in, &exp, 0) != 0) return false; - if (exp.we_wordc == 1) + if (exp.we_wordc >= 1) { result = true; - ffStrbufSetS(out, exp.we_wordv[0]); + ffStrbufSetS(out, exp.we_wordv[exp.we_wordc > 1 ? ffTimeGetNow() % exp.we_wordc : 0]); } wordfree(&exp); @@ -159,10 +160,10 @@ bool ffPathExpandEnv(FF_MAYBE_UNUSED const char* in, FF_MAYBE_UNUSED FFstrbuf* o if (glob(in, GLOB_NOSORT | GLOB_TILDE, NULL, &gb) != 0) return false; - if (gb.gl_matchc == 1) + if (gb.gl_matchc >= 1) { result = true; - ffStrbufSetS(out, gb.gl_pathv[0]); + ffStrbufSetS(out, gb.gl_pathv[gb.gl_matchc > 1 ? ffTimeGetNow() % gb.gl_matchc : 0]); } globfree(&gb); diff --git a/src/common/option.h b/src/common/option.h index b9f3fb311..689881a0a 100644 --- a/src/common/option.h +++ b/src/common/option.h @@ -6,6 +6,20 @@ struct yyjson_val; struct yyjson_mut_doc; struct yyjson_mut_val; +typedef struct FFModuleFormatArg +{ + const char* desc; + const char* name; +} FFModuleFormatArg; + +typedef struct FFModuleFormatArgList +{ + FFModuleFormatArg* args; + uint32_t count; +} FFModuleFormatArgList; + +#define FF_FORMAT_ARG_LIST(list) { .args = list, .count = sizeof(list) / sizeof(FFModuleFormatArg) } + // Must be the first field of FFModuleOptions typedef struct FFModuleBaseInfo { @@ -19,32 +33,10 @@ typedef struct FFModuleBaseInfo void (*parseJsonObject)(void* options, struct yyjson_val *module); void (*printModule)(void* options); void (*generateJsonResult)(void* options, struct yyjson_mut_doc* doc, struct yyjson_mut_val* module); - void (*printHelpFormat)(void); void (*generateJsonConfig)(void* options, struct yyjson_mut_doc* doc, struct yyjson_mut_val* obj); + FFModuleFormatArgList formatArgs; } 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) - void* generateJsonResult, // void (*const generateJsonResult)(void* options, yyjson_mut_doc* doc, yyjson_mut_val* obj) - void (*printHelpFormat)(void), - void* generateJsonConfig // void (*const generateJsonConfig)(void* options, yyjson_mut_doc* doc, yyjson_mut_val* obj) -) -{ - baseInfo->name = name; - baseInfo->description = description; - baseInfo->parseCommandOptions = (__typeof__(baseInfo->parseCommandOptions)) parseCommandOptions; - baseInfo->parseJsonObject = (__typeof__(baseInfo->parseJsonObject)) parseJsonObject; - baseInfo->printModule = (__typeof__(baseInfo->printModule)) printModule; - baseInfo->generateJsonResult = (__typeof__(baseInfo->generateJsonResult)) generateJsonResult; - baseInfo->printHelpFormat = printHelpFormat; - baseInfo->generateJsonConfig = (__typeof__(baseInfo->generateJsonConfig)) generateJsonConfig; -} - typedef enum __attribute__((__packed__)) FFModuleKeyType { FF_MODULE_KEY_TYPE_NONE = 0, diff --git a/src/common/printing.c b/src/common/printing.c index c2112b6b0..ac8fd3055 100644 --- a/src/common/printing.c +++ b/src/common/printing.c @@ -50,7 +50,7 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu else { FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); - FF_PARSE_FORMAT_STRING_CHECKED(&key, &moduleArgs->key, 2, ((FFformatarg[]){ + FF_PARSE_FORMAT_STRING_CHECKED(&key, &moduleArgs->key, ((FFformatarg[]) { FF_FORMAT_ARG(moduleIndex, "index"), FF_FORMAT_ARG(moduleArgs->keyIcon, "icon"), })); @@ -148,18 +148,3 @@ void ffPrintCharTimes(char c, uint32_t times) if(remaining > 0) fwrite(str, 1, remaining, stdout); } - -void ffPrintModuleFormatHelp(const char* name, const char* def, uint32_t numArgs, const char* args[]) -{ - FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateS(name); - ffStrbufLowerCase(&buffer); - printf("--%s-format:\n", buffer.chars); - printf("Sets the format string for %s output.\n", name); - puts("To see how a format string is constructed, take a look at \"fastfetch --help format\"."); - puts("The following values are passed:"); - - for(unsigned i = 0; i < numArgs; i++) - printf(" {%u}: %s\n", i + 1, args[i]); - - printf("The default is something similar to \"%s\".\n", def); -} diff --git a/src/common/printing.h b/src/common/printing.h index 94479dc03..1ee79d540 100644 --- a/src/common/printing.h +++ b/src/common/printing.h @@ -14,16 +14,8 @@ typedef enum __attribute__((__packed__)) FFPrintType { void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType); void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments); -#define FF_PRINT_FORMAT_CHECKED(moduleName, moduleIndex, moduleArgs, printType, numArgs, arguments) do {\ - static_assert(sizeof(arguments) / sizeof(*arguments) == (numArgs), "Invalid number of format arguments");\ - ffPrintFormat((moduleName), (moduleIndex), (moduleArgs), (printType), (numArgs), (arguments));\ -} while (0) +#define FF_PRINT_FORMAT_CHECKED(moduleName, moduleIndex, moduleArgs, printType, arguments) \ + ffPrintFormat((moduleName), (moduleIndex), (moduleArgs), (printType), (sizeof(arguments) / sizeof(*arguments)), (arguments)); FF_C_PRINTF(5, 6) void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...); void ffPrintColor(const FFstrbuf* colorValue); void ffPrintCharTimes(char c, uint32_t times); - -void ffPrintModuleFormatHelp(const char* name, const char* def, uint32_t numArgs, const char* args[]); -#define FF_PRINT_MODULE_FORMAT_HELP_CHECKED(moduleName, def, numArgs, args) do {\ - static_assert(sizeof(args) / sizeof(*args) == (numArgs), "Invalid number of format arguments");\ - ffPrintModuleFormatHelp((moduleName), (def), (numArgs), (args));\ -} while (0) diff --git a/src/detection/cpu/cpu_arm.h b/src/detection/cpu/cpu_arm.h index 3ff408cd7..1a6be1152 100644 --- a/src/detection/cpu/cpu_arm.h +++ b/src/detection/cpu/cpu_arm.h @@ -168,7 +168,8 @@ static const char* qcomPartId2name(uint32_t partId) { switch (partId) { - case 0x001: return "Oryon"; + case 0x001: return "Oryon 1"; + case 0x002: return "Oryon 2"; case 0x00f: return "Scorpion"; case 0x02d: return "Scorpion"; case 0x04d: return "Krait"; @@ -262,6 +263,9 @@ static const char* applePartId2name(uint32_t partId) case 0x037: return "Everest-A16"; case 0x038: return "Blizzard-M2-Max"; case 0x039: return "Avalanche-M2-Max"; + case 0x046: return "Sawtooth-M11"; + case 0x048: return "Sawtooth-M3-Max"; + case 0x049: return "Everest-M3-Max"; default: return NULL; } } diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index 326d28e6f..3fc9c8557 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -170,28 +170,33 @@ static void detectArmName(FFstrbuf* cpuinfo, FFCPUResult* cpu, uint32_t implId) if (!ffStrStartsWith(line, "CPU part\t: ")) continue; uint32_t partId = (uint32_t) strtoul(line + strlen("CPU part\t: "), NULL, 16); const char* name = NULL; - if (partId > 0) // Linux reports 0 for unknown CPUs + switch (implId) { - switch (implId) - { - case 0x41: name = armPartId2name(partId); break; - case 0x42: name = brcmPartId2name(partId); break; - case 0x43: name = caviumPartId2name(partId); break; - case 0x44: name = decPartId2name(partId); break; - case 0x46: name = fujitsuPartId2name(partId); break; - case 0x48: name = hisiPartId2name(partId); break; - case 0x4e: name = nvidiaPartId2name(partId); break; - case 0x50: name = apmPartId2name(partId); break; - case 0x51: name = qcomPartId2name(partId); break; - case 0x53: name = samsungPartId2name(partId); break; - case 0x56: name = marvellPartId2name(partId); break; - case 0x61: name = applePartId2name(partId); break; - case 0x66: name = faradayPartId2name(partId); break; - case 0x69: name = intelPartId2name(partId); break; - case 0x6d: name = msPartId2name(partId); break; - case 0x70: name = ftPartId2name(partId); break; - case 0xc0: name = amperePartId2name(partId); break; - } + case 0x41: name = armPartId2name(partId); break; + case 0x42: name = brcmPartId2name(partId); break; + case 0x43: name = caviumPartId2name(partId); break; + case 0x44: name = decPartId2name(partId); break; + case 0x46: name = fujitsuPartId2name(partId); break; + case 0x48: name = hisiPartId2name(partId); break; + case 0x4e: name = nvidiaPartId2name(partId); break; + case 0x50: name = apmPartId2name(partId); break; + case 0x51: name = qcomPartId2name(partId); break; + case 0x53: name = samsungPartId2name(partId); break; + case 0x56: name = marvellPartId2name(partId); break; + case 0x61: + if (partId == 0) + { + // https://github.com/Dr-Noob/cpufetch/issues/213#issuecomment-1927782105 + ffStrbufSetStatic(&cpu->name, "Virtualized Apple Silicon"); + return; + } + name = applePartId2name(partId); + break; + case 0x66: name = faradayPartId2name(partId); break; + case 0x69: name = intelPartId2name(partId); break; + case 0x6d: name = msPartId2name(partId); break; + case 0x70: name = ftPartId2name(partId); break; + case 0xc0: name = amperePartId2name(partId); break; } if (lastPartId != partId) { diff --git a/src/detection/displayserver/displayserver.h b/src/detection/displayserver/displayserver.h index dd4fd9651..7949f61ec 100644 --- a/src/detection/displayserver/displayserver.h +++ b/src/detection/displayserver/displayserver.h @@ -36,7 +36,9 @@ #define FF_WM_PRETTY_ICEWM "IceWM" #define FF_WM_PRETTY_SPECTRWM "spectrwm" #define FF_WM_PRETTY_DTWM "dtwm" - +#define FF_WM_PRETTY_FVWM "fvwm" +#define FF_WM_PRETTY_CTWM "ctwm" +#define FF_WM_PRETTY_RATPOISON "ratpoison" #define FF_WM_PROTOCOL_TTY "TTY" #define FF_WM_PROTOCOL_X11 "X11" diff --git a/src/detection/displayserver/linux/wayland/kde-output.c b/src/detection/displayserver/linux/wayland/kde-output.c index 6644880e0..a47548ea4 100644 --- a/src/detection/displayserver/linux/wayland/kde-output.c +++ b/src/detection/displayserver/linux/wayland/kde-output.c @@ -126,10 +126,7 @@ static void waylandKdeNameListener(void* data, FF_MAYBE_UNUSED struct kde_output WaylandDisplay* display = data; display->type = ffdsGetDisplayType(name); // As display->id is used as an internal identifier, we don't need it to be NUL terminated - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wstringop-truncation" strncpy((char*) &display->id, name, sizeof(display->id)); - #pragma GCC diagnostic pop ffStrbufAppendS(&display->name, name); } diff --git a/src/detection/displayserver/linux/wayland/wayland.c b/src/detection/displayserver/linux/wayland/wayland.c index d09eb06f9..d19e3733c 100644 --- a/src/detection/displayserver/linux/wayland/wayland.c +++ b/src/detection/displayserver/linux/wayland/wayland.c @@ -18,10 +18,18 @@ #include "kde-output-order-v1-client-protocol.h" #include "xdg-output-unstable-v1-client-protocol.h" -#ifdef __linux__ +#if __FreeBSD__ +#include +#include +#include +#endif + static bool waylandDetectWM(int fd, FFDisplayServerResult* result) { - struct ucred ucred; +#if __linux__ || (__FreeBSD__ && !__DragonFly__) + +#if __linux + struct ucred ucred = {}; socklen_t len = sizeof(ucred); if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == -1 || ucred.pid <= 0) return false; @@ -30,6 +38,19 @@ static bool waylandDetectWM(int fd, FFDisplayServerResult* result) ffStrbufAppendF(&procPath, "/proc/%d/cmdline", ucred.pid); //We check the cmdline for the process name, because it is not trimmed. if (!ffReadFileBuffer(procPath.chars, &result->wmProcessName)) return false; +#else + struct xucred ucred = {}; + socklen_t len = sizeof(ucred); + if (getsockopt(fd, AF_UNSPEC, LOCAL_PEERCRED, &ucred, &len) == -1 || ucred.cr_pid <= 0) + return false; + + size_t size = 4096; + ffStrbufEnsureFixedLengthFree(&result->wmProcessName, (uint32_t) size); + + if(sysctl((int[]){CTL_KERN, KERN_PROC, KERN_PROC_ARGS, ucred.cr_pid}, 4, result->wmProcessName.chars, &size, NULL, 0 ) != 0) + return false; + result->wmProcessName.length = (uint32_t) size - 1; +#endif // #1135: wl-restart is a special case const char* filename = strrchr(result->wmProcessName.chars, '/'); @@ -45,14 +66,12 @@ static bool waylandDetectWM(int fd, FFDisplayServerResult* result) ffStrbufSubstrAfterLastC(&result->wmProcessName, '/'); //Trim the path return true; -} + #else -static bool waylandDetectWM(int fd, FFDisplayServerResult* result) -{ FF_UNUSED(fd, result); return false; -} #endif +} static void waylandGlobalAddListener(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version) { @@ -83,7 +102,7 @@ static void waylandGlobalAddListener(void* data, struct wl_registry* registry, u } } -static bool matchDrmConnector(const char* connName, WaylandDisplay* wldata) +static FF_MAYBE_UNUSED bool matchDrmConnector(const char* connName, WaylandDisplay* wldata) { // https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-event-name // The doc says that "do not assume that the name is a reflection of an underlying DRM connector, X11 connection, etc." @@ -129,8 +148,10 @@ void ffWaylandOutputNameListener(void* data, FF_MAYBE_UNUSED void* output, const if (display->id) return; display->type = ffdsGetDisplayType(name); + #if __linux__ if (!display->edidName.length) matchDrmConnector(name, display); + #endif display->id = ffWaylandGenerateIdFromName(name); ffStrbufAppendS(&display->name, name); } diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index 7a8554caa..557be31aa 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -126,8 +126,14 @@ static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* name) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_ICEWM); else if(ffStrEqualsIgnCase(name, "dtwm")) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_DTWM); + else if(ffStrEqualsIgnCase(name, "fvwm")) + ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_FVWM); + else if(ffStrEqualsIgnCase(name, "ctwm")) + ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_CTWM); else if(ffStrEqualsIgnCase(name, "hyprland")) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_HYPRLAND); + else if(ffStrEqualsIgnCase(name, "ratpoison")) + ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_RATPOISON); } static void applyNameIfWM(FFDisplayServerResult* result, const char* processName) @@ -296,10 +302,10 @@ static const char* getFromProcesses(FFDisplayServerResult* result) for (int i = 0; i < count; ++i) { if(result->dePrettyName.length == 0) - applyPrettyNameIfDE(result, proc->p_comm); + applyPrettyNameIfDE(result, proc[i].p_comm); if(result->wmPrettyName.length == 0) - applyNameIfWM(result, proc->p_comm); + applyNameIfWM(result, proc[i].p_comm); if(result->dePrettyName.length > 0 && result->wmPrettyName.length > 0) break; diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index b3eab2dec..13f8537ae 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -188,7 +188,6 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrb { item->hdrStatus = ffEdidGetHdrCompatible(edidData, (uint32_t) edidLength) ? FF_DISPLAY_HDR_STATUS_SUPPORTED : FF_DISPLAY_HDR_STATUS_UNSUPPORTED; ffEdidGetSerialAndManufactureDate(edidData, &item->serial, &item->manufactureYear, &item->manufactureWeek); - ffEdidGetPhysicalSize(edidData, &item->physicalWidth, &item->physicalHeight); } return !!item; diff --git a/src/detection/displayserver/linux/xlib.c b/src/detection/displayserver/linux/xlib.c index d2a1d1f24..0c4d283ed 100644 --- a/src/detection/displayserver/linux/xlib.c +++ b/src/detection/displayserver/linux/xlib.c @@ -151,7 +151,6 @@ static bool xrandrHandleCrtc(XrandrData* data, XRROutputInfo* output, FFstrbuf* { item->hdrStatus = ffEdidGetHdrCompatible(edidData, edidLength) ? FF_DISPLAY_HDR_STATUS_SUPPORTED : FF_DISPLAY_HDR_STATUS_UNSUPPORTED; ffEdidGetSerialAndManufactureDate(edidData, &item->serial, &item->manufactureYear, &item->manufactureWeek); - ffEdidGetPhysicalSize(edidData, &item->physicalWidth, &item->physicalHeight); } data->ffXRRFreeCrtcInfo(crtcInfo); diff --git a/src/detection/gpu/gpu_pci.c b/src/detection/gpu/gpu_pci.c index 2de51a2ca..f06358236 100644 --- a/src/detection/gpu/gpu_pci.c +++ b/src/detection/gpu/gpu_pci.c @@ -3,10 +3,14 @@ #include #ifdef __FreeBSD__ -#include + #include #ifndef _PATH_LOCALBASE #define _PATH_LOCALBASE "/usr/local" #endif +#elif __OpenBSD__ + #define _PATH_LOCALBASE "/usr/local" +#elif __NetBSD__ + #define _PATH_LOCALBASE "/usr/pkg" #endif #if FF_HAVE_EMBEDDED_PCIIDS @@ -37,17 +41,10 @@ static const FFstrbuf* loadPciIds() if (pciids.length == 0) ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/local/share/hwdata/pci.ids", &pciids); } - #elif __FreeBSD__ - // https://github.com/freebsd/freebsd-src/blob/main/usr.sbin/pciconf/pathnames.h + #elif __FreeBSD__ || __OpenBSD__ || __NetBSD__ ffReadFileBuffer(_PATH_LOCALBASE "/share/pciids/pci.ids", &pciids); - if (pciids.length == 0) - ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/share/pciids/pci.ids", &pciids); #elif __sun ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/usr/share/hwdata/pci.ids", &pciids); - #elif __OpenBSD__ - ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/usr/local/share/pci.ids", &pciids); - #elif __NetBSD__ - ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/usr/pkg/share/pciutils/pci.ids", &pciids); #endif #endif // FF_CUSTOM_PCI_IDS_PATH diff --git a/src/detection/host/host.h b/src/detection/host/host.h index 1b0c61187..a1e733e01 100644 --- a/src/detection/host/host.h +++ b/src/detection/host/host.h @@ -13,4 +13,8 @@ typedef struct FFHostResult FFstrbuf vendor; } FFHostResult; +const char* ffHostGetMacProductNameWithHwModel(const FFstrbuf* hwModel); +#ifdef __x86_64__ +bool ffHostDetectMac(FFHostResult* host); +#endif const char* ffDetectHost(FFHostResult* host); diff --git a/src/detection/host/host_apple.c b/src/detection/host/host_apple.c index 552ab8978..c83b09684 100644 --- a/src/detection/host/host_apple.c +++ b/src/detection/host/host_apple.c @@ -5,179 +5,6 @@ #include -static const char* getProductNameWithHwModel(const FFstrbuf* hwModel) -{ - // Macbook Pro: https://support.apple.com/en-us/HT201300 - // Macbook Air: https://support.apple.com/en-us/HT201862 - // Mac mini: https://support.apple.com/en-us/HT201894 - // iMac: https://support.apple.com/en-us/HT201634 - // Mac Pro: https://support.apple.com/en-us/HT202888 - // Mac Studio: https://support.apple.com/en-us/HT213073 - - if(ffStrbufStartsWithS(hwModel, "MacBookPro")) - { - const char* version = hwModel->chars + strlen("MacBookPro"); - if(ffStrEquals(version, "18,3") || - ffStrEquals(version, "18,4")) return "MacBook Pro (14-inch, 2021)"; - if(ffStrEquals(version, "18,1") || - ffStrEquals(version, "18,2")) return "MacBook Pro (16-inch, 2021)"; - if(ffStrEquals(version, "17,1")) return "MacBook Pro (13-inch, M1, 2020)"; - if(ffStrEquals(version, "16,3")) return "MacBook Pro (13-inch, 2020, Two Thunderbolt 3 ports)"; - if(ffStrEquals(version, "16,2")) return "MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)"; - if(ffStrEquals(version, "16,4") || - ffStrEquals(version, "16,1")) return "MacBook Pro (16-inch, 2019)"; - if(ffStrEquals(version, "15,4")) return "MacBook Pro (13-inch, 2019, Two Thunderbolt 3 ports)"; - if(ffStrEquals(version, "15,3")) return "MacBook Pro (15-inch, 2019)"; - if(ffStrEquals(version, "15,2")) return "MacBook Pro (13-inch, 2018/2019, Four Thunderbolt 3 ports)"; - if(ffStrEquals(version, "15,1")) return "MacBook Pro (15-inch, 2018/2019)"; - if(ffStrEquals(version, "14,3")) return "MacBook Pro (15-inch, 2017)"; - if(ffStrEquals(version, "14,2")) return "MacBook Pro (13-inch, 2017, Four Thunderbolt 3 ports)"; - if(ffStrEquals(version, "14,1")) return "MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports)"; - if(ffStrEquals(version, "13,3")) return "MacBook Pro (15-inch, 2016)"; - if(ffStrEquals(version, "13,2")) return "MacBook Pro (13-inch, 2016, Four Thunderbolt 3 ports)"; - if(ffStrEquals(version, "13,1")) return "MacBook Pro (13-inch, 2016, Two Thunderbolt 3 ports)"; - if(ffStrEquals(version, "12,1")) return "MacBook Pro (Retina, 13-inch, Early 2015)"; - if(ffStrEquals(version, "11,4") || - ffStrEquals(version, "11,5")) return "MacBook Pro (Retina, 15-inch, Mid 2015)"; - if(ffStrEquals(version, "11,2") || - ffStrEquals(version, "11,3")) return "MacBook Pro (Retina, 15-inch, Late 2013/Mid 2014)"; - if(ffStrEquals(version, "11,1")) return "MacBook Pro (Retina, 13-inch, Late 2013/Mid 2014)"; - if(ffStrEquals(version, "10,2")) return "MacBook Pro (Retina, 13-inch, Late 2012/Early 2013)"; - if(ffStrEquals(version, "10,1")) return "MacBook Pro (Retina, 15-inch, Mid 2012/Early 2013)"; - if(ffStrEquals(version, "9,2")) return "MacBook Pro (13-inch, Mid 2012)"; - if(ffStrEquals(version, "9,1")) return "MacBook Pro (15-inch, Mid 2012)"; - if(ffStrEquals(version, "8,3")) return "MacBook Pro (17-inch, 2011)"; - if(ffStrEquals(version, "8,2")) return "MacBook Pro (15-inch, 2011)"; - if(ffStrEquals(version, "8,1")) return "MacBook Pro (13-inch, 2011)"; - if(ffStrEquals(version, "7,1")) return "MacBook Pro (13-inch, Mid 2010)"; - if(ffStrEquals(version, "6,2")) return "MacBook Pro (15-inch, Mid 2010)"; - if(ffStrEquals(version, "6,1")) return "MacBook Pro (17-inch, Mid 2010)"; - if(ffStrEquals(version, "5,5")) return "MacBook Pro (13-inch, Mid 2009)"; - if(ffStrEquals(version, "5,3")) return "MacBook Pro (15-inch, Mid 2009)"; - if(ffStrEquals(version, "5,2")) return "MacBook Pro (17-inch, Mid/Early 2009)"; - if(ffStrEquals(version, "5,1")) return "MacBook Pro (15-inch, Late 2008)"; - if(ffStrEquals(version, "4,1")) return "MacBook Pro (17/15-inch, Early 2008)"; - } - else if(ffStrbufStartsWithS(hwModel, "MacBookAir")) - { - const char* version = hwModel->chars + strlen("MacBookAir"); - if(ffStrEquals(version, "10,1")) return "MacBook Air (M1, 2020)"; - if(ffStrEquals(version, "9,1")) return "MacBook Air (Retina, 13-inch, 2020)"; - if(ffStrEquals(version, "8,2")) return "MacBook Air (Retina, 13-inch, 2019)"; - if(ffStrEquals(version, "8,1")) return "MacBook Air (Retina, 13-inch, 2018)"; - if(ffStrEquals(version, "7,2")) return "MacBook Air (13-inch, Early 2015/2017)"; - if(ffStrEquals(version, "7,1")) return "MacBook Air (11-inch, Early 2015)"; - if(ffStrEquals(version, "6,2")) return "MacBook Air (13-inch, Mid 2013/Early 2014)"; - if(ffStrEquals(version, "6,1")) return "MacBook Air (11-inch, Mid 2013/Early 2014)"; - if(ffStrEquals(version, "5,2")) return "MacBook Air (13-inch, Mid 2012)"; - if(ffStrEquals(version, "5,1")) return "MacBook Air (11-inch, Mid 2012)"; - if(ffStrEquals(version, "4,2")) return "MacBook Air (13-inch, Mid 2011)"; - if(ffStrEquals(version, "4,1")) return "MacBook Air (11-inch, Mid 2011)"; - if(ffStrEquals(version, "3,2")) return "MacBook Air (13-inch, Late 2010)"; - if(ffStrEquals(version, "3,1")) return "MacBook Air (11-inch, Late 2010)"; - if(ffStrEquals(version, "2,1")) return "MacBook Air (Mid 2009)"; - } - else if(ffStrbufStartsWithS(hwModel, "Macmini")) - { - const char* version = hwModel->chars + strlen("Macmini"); - if(ffStrEquals(version, "9,1")) return "Mac mini (M1, 2020)"; - if(ffStrEquals(version, "8,1")) return "Mac mini (2018)"; - if(ffStrEquals(version, "7,1")) return "Mac mini (Mid 2014)"; - if(ffStrEquals(version, "6,1") || - ffStrEquals(version, "6,2")) return "Mac mini (Late 2012)"; - if(ffStrEquals(version, "5,1") || - ffStrEquals(version, "5,2")) return "Mac mini (Mid 2011)"; - if(ffStrEquals(version, "4,1")) return "Mac mini (Mid 2010)"; - if(ffStrEquals(version, "3,1")) return "Mac mini (Early/Late 2009)"; - } - else if(ffStrbufStartsWithS(hwModel, "MacBook")) - { - const char* version = hwModel->chars + strlen("MacBook"); - if(ffStrEquals(version, "10,1")) return "MacBook (Retina, 12-inch, 2017)"; - if(ffStrEquals(version, "9,1")) return "MacBook (Retina, 12-inch, Early 2016)"; - if(ffStrEquals(version, "8,1")) return "MacBook (Retina, 12-inch, Early 2015)"; - if(ffStrEquals(version, "7,1")) return "MacBook (13-inch, Mid 2010)"; - if(ffStrEquals(version, "6,1")) return "MacBook (13-inch, Late 2009)"; - if(ffStrEquals(version, "5,2")) return "MacBook (13-inch, Early/Mid 2009)"; - } - else if(ffStrbufStartsWithS(hwModel, "MacPro")) - { - const char* version = hwModel->chars + strlen("MacPro"); - if(ffStrEquals(version, "7,1")) return "Mac Pro (2019)"; - if(ffStrEquals(version, "6,1")) return "Mac Pro (Late 2013)"; - if(ffStrEquals(version, "5,1")) return "Mac Pro (Mid 2010 - Mid 2012)"; - if(ffStrEquals(version, "4,1")) return "Mac Pro (Early 2009)"; - } - else if(ffStrbufStartsWithS(hwModel, "Mac")) - { - const char* version = hwModel->chars + strlen("Mac"); - if(ffStrEquals(version, "16,3")) return "iMac (24-inch, 2024, Four Thunderbolt / USB 4 ports)"; - if(ffStrEquals(version, "16,2")) return "iMac (24-inch, 2024, Two Thunderbolt / USB 4 ports)"; - if(ffStrEquals(version, "16,1") || - ffStrEquals(version, "16,6") || - ffStrEquals(version, "16,8")) return "MacBook Pro (14-inch, 2024, Three Thunderbolt 4 ports)"; - if(ffStrEquals(version, "16,7") || - ffStrEquals(version, "16,5")) return "MacBook Pro (16-inch, 2024, Three Thunderbolt 4 ports)"; - if(ffStrEquals(version, "16,15") || - ffStrEquals(version, "16,10")) return "Mac mini (2024)"; - if(ffStrEquals(version, "15,13")) return "MacBook Air (15-inch, M3, 2024)"; - if(ffStrEquals(version, "15,2")) return "MacBook Air (13-inch, M3, 2024)"; - if(ffStrEquals(version, "15,3")) return "MacBook Pro (14-inch, Nov 2023, Two Thunderbolt / USB 4 ports)"; - if(ffStrEquals(version, "15,4")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports)"; - if(ffStrEquals(version, "15,5")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports, Two USB 3 ports)"; - if(ffStrEquals(version, "15,6") || - ffStrEquals(version, "15,8") || - ffStrEquals(version, "15,10")) return "MacBook Pro (14-inch, Nov 2023, Three Thunderbolt 4 ports)"; - if(ffStrEquals(version, "15,7") || - ffStrEquals(version, "15,9") || - ffStrEquals(version, "15,11")) return "MacBook Pro (16-inch, Nov 2023, Three Thunderbolt 4 ports)"; - if(ffStrEquals(version, "14,15")) return "MacBook Air (15-inch, M2, 2023)"; - if(ffStrEquals(version, "14,14")) return "Mac Studio (M2 Ultra, 2023, Two Thunderbolt 4 front ports)"; - if(ffStrEquals(version, "14,13")) return "Mac Studio (M2 Max, 2023, Two USB-C front ports)"; - if(ffStrEquals(version, "14,8")) return "Mac Pro (2023)"; - if(ffStrEquals(version, "14,6") || - ffStrEquals(version, "14,10")) return "MacBook Pro (16-inch, 2023)"; - if(ffStrEquals(version, "14,5") || - ffStrEquals(version, "14,9")) return "MacBook Pro (14-inch, 2023)"; - if(ffStrEquals(version, "14,3")) return "Mac mini (M2, 2023, Two Thunderbolt 4 ports)"; - if(ffStrEquals(version, "14,12")) return "Mac mini (M2, 2023, Four Thunderbolt 4 ports)"; - if(ffStrEquals(version, "14,7")) return "MacBook Pro (13-inch, M2, 2022)"; - if(ffStrEquals(version, "14,2")) return "MacBook Air (M2, 2022)"; - if(ffStrEquals(version, "13,1")) return "Mac Studio (M1 Max, 2022, Two USB-C front ports)"; - if(ffStrEquals(version, "13,2")) return "Mac Studio (M1 Ultra, 2022, Two Thunderbolt 4 front ports)"; - } - else if(ffStrbufStartsWithS(hwModel, "iMac")) - { - const char* version = hwModel->chars + strlen("iMac"); - if(ffStrEquals(version, "21,1")) return "iMac (24-inch, M1, 2021, Two Thunderbolt / USB 4 ports, Two USB 3 ports)"; - if(ffStrEquals(version, "21,2")) return "iMac (24-inch, M1, 2021, Two Thunderbolt / USB 4 ports)"; - if(ffStrEquals(version, "20,1") || - ffStrEquals(version, "20,2")) return "iMac (Retina 5K, 27-inch, 2020)"; - if(ffStrEquals(version, "19,1")) return "iMac (Retina 5K, 27-inch, 2019)"; - if(ffStrEquals(version, "19,2")) return "iMac (Retina 4K, 21.5-inch, 2019)"; - if(ffStrEquals(version, "Pro1,1")) return "iMac Pro (2017)"; - if(ffStrEquals(version, "18,3")) return "iMac (Retina 5K, 27-inch, 2017)"; - if(ffStrEquals(version, "18,2")) return "iMac (Retina 4K, 21.5-inch, 2017)"; - if(ffStrEquals(version, "18,1")) return "iMac (21.5-inch, 2017)"; - if(ffStrEquals(version, "17,1")) return "iMac (Retina 5K, 27-inch, Late 2015)"; - if(ffStrEquals(version, "16,2")) return "iMac (Retina 4K, 21.5-inch, Late 2015)"; - if(ffStrEquals(version, "16,1")) return "iMac (21.5-inch, Late 2015)"; - if(ffStrEquals(version, "15,1")) return "iMac (Retina 5K, 27-inch, Late 2014 - Mid 2015)"; - if(ffStrEquals(version, "14,4")) return "iMac (21.5-inch, Mid 2014)"; - if(ffStrEquals(version, "14,2")) return "iMac (27-inch, Late 2013)"; - if(ffStrEquals(version, "14,1")) return "iMac (21.5-inch, Late 2013)"; - if(ffStrEquals(version, "13,2")) return "iMac (27-inch, Late 2012)"; - if(ffStrEquals(version, "13,1")) return "iMac (21.5-inch, Late 2012)"; - if(ffStrEquals(version, "12,2")) return "iMac (27-inch, Mid 2011)"; - if(ffStrEquals(version, "12,1")) return "iMac (21.5-inch, Mid 2011)"; - if(ffStrEquals(version, "11,3")) return "iMac (27-inch, Mid 2010)"; - if(ffStrEquals(version, "11,2")) return "iMac (21.5-inch, Mid 2010)"; - if(ffStrEquals(version, "10,1")) return "iMac (27/21.5-inch, Late 2009)"; - if(ffStrEquals(version, "9,1")) return "iMac (24/20-inch, Early 2009)"; - } - return NULL; -} - const char* getProductNameWithIokit(FFstrbuf* result) { FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t registryEntry = IOServiceGetMatchingService(MACH_PORT_NULL, IOServiceNameMatching("product")); @@ -217,7 +44,7 @@ const char* ffDetectHost(FFHostResult* host) const char* error = ffSysctlGetString("hw.model", &host->family); if (error) return error; - ffStrbufSetStatic(&host->name, getProductNameWithHwModel(&host->family)); + ffStrbufSetStatic(&host->name, ffHostGetMacProductNameWithHwModel(&host->family)); if (host->name.length == 0) getProductNameWithIokit(&host->name); if (host->name.length == 0) diff --git a/src/detection/host/host_bsd.c b/src/detection/host/host_bsd.c index 334b04cab..5de12117e 100644 --- a/src/detection/host/host_bsd.c +++ b/src/detection/host/host_bsd.c @@ -19,5 +19,9 @@ const char* ffDetectHost(FFHostResult* host) ffSettingsGetFreeBSDKenv("smbios.system.maker", &host->vendor); ffCleanUpSmbiosValue(&host->vendor); + #ifdef __x86_64__ + ffHostDetectMac(host); + #endif + return NULL; } diff --git a/src/detection/host/host_linux.c b/src/detection/host/host_linux.c index 41b1733b8..2ed4d71ad 100644 --- a/src/detection/host/host_linux.c +++ b/src/detection/host/host_linux.c @@ -63,6 +63,10 @@ const char* ffDetectHost(FFHostResult* host) ffStrbufSetStatic(&host->vendor, "Apple Inc."); } + #ifdef __x86_64__ + ffHostDetectMac(host); + #endif + //KVM/Qemu virtual machine if(ffStrbufStartsWithS(&host->name, "Standard PC")) ffStrbufPrependS(&host->name, "KVM/QEMU "); diff --git a/src/detection/host/host_mac.c b/src/detection/host/host_mac.c new file mode 100644 index 000000000..8f8551cfc --- /dev/null +++ b/src/detection/host/host_mac.c @@ -0,0 +1,193 @@ +#include "host.h" +#include "util/stringUtils.h" + +const char* ffHostGetMacProductNameWithHwModel(const FFstrbuf* hwModel) +{ + // Macbook Pro: https://support.apple.com/en-us/HT201300 + // Macbook Air: https://support.apple.com/en-us/HT201862 + // Mac mini: https://support.apple.com/en-us/HT201894 + // iMac: https://support.apple.com/en-us/HT201634 + // Mac Pro: https://support.apple.com/en-us/HT202888 + // Mac Studio: https://support.apple.com/en-us/HT213073 + + if(ffStrbufStartsWithS(hwModel, "MacBookPro")) + { + const char* version = hwModel->chars + strlen("MacBookPro"); + if(ffStrEquals(version, "18,3") || + ffStrEquals(version, "18,4")) return "MacBook Pro (14-inch, 2021)"; + if(ffStrEquals(version, "18,1") || + ffStrEquals(version, "18,2")) return "MacBook Pro (16-inch, 2021)"; + if(ffStrEquals(version, "17,1")) return "MacBook Pro (13-inch, M1, 2020)"; + if(ffStrEquals(version, "16,3")) return "MacBook Pro (13-inch, 2020, Two Thunderbolt 3 ports)"; + if(ffStrEquals(version, "16,2")) return "MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)"; + if(ffStrEquals(version, "16,4") || + ffStrEquals(version, "16,1")) return "MacBook Pro (16-inch, 2019)"; + if(ffStrEquals(version, "15,4")) return "MacBook Pro (13-inch, 2019, Two Thunderbolt 3 ports)"; + if(ffStrEquals(version, "15,3")) return "MacBook Pro (15-inch, 2019)"; + if(ffStrEquals(version, "15,2")) return "MacBook Pro (13-inch, 2018/2019, Four Thunderbolt 3 ports)"; + if(ffStrEquals(version, "15,1")) return "MacBook Pro (15-inch, 2018/2019)"; + if(ffStrEquals(version, "14,3")) return "MacBook Pro (15-inch, 2017)"; + if(ffStrEquals(version, "14,2")) return "MacBook Pro (13-inch, 2017, Four Thunderbolt 3 ports)"; + if(ffStrEquals(version, "14,1")) return "MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports)"; + if(ffStrEquals(version, "13,3")) return "MacBook Pro (15-inch, 2016)"; + if(ffStrEquals(version, "13,2")) return "MacBook Pro (13-inch, 2016, Four Thunderbolt 3 ports)"; + if(ffStrEquals(version, "13,1")) return "MacBook Pro (13-inch, 2016, Two Thunderbolt 3 ports)"; + if(ffStrEquals(version, "12,1")) return "MacBook Pro (Retina, 13-inch, Early 2015)"; + if(ffStrEquals(version, "11,4") || + ffStrEquals(version, "11,5")) return "MacBook Pro (Retina, 15-inch, Mid 2015)"; + if(ffStrEquals(version, "11,2") || + ffStrEquals(version, "11,3")) return "MacBook Pro (Retina, 15-inch, Late 2013/Mid 2014)"; + if(ffStrEquals(version, "11,1")) return "MacBook Pro (Retina, 13-inch, Late 2013/Mid 2014)"; + if(ffStrEquals(version, "10,2")) return "MacBook Pro (Retina, 13-inch, Late 2012/Early 2013)"; + if(ffStrEquals(version, "10,1")) return "MacBook Pro (Retina, 15-inch, Mid 2012/Early 2013)"; + if(ffStrEquals(version, "9,2")) return "MacBook Pro (13-inch, Mid 2012)"; + if(ffStrEquals(version, "9,1")) return "MacBook Pro (15-inch, Mid 2012)"; + if(ffStrEquals(version, "8,3")) return "MacBook Pro (17-inch, 2011)"; + if(ffStrEquals(version, "8,2")) return "MacBook Pro (15-inch, 2011)"; + if(ffStrEquals(version, "8,1")) return "MacBook Pro (13-inch, 2011)"; + if(ffStrEquals(version, "7,1")) return "MacBook Pro (13-inch, Mid 2010)"; + if(ffStrEquals(version, "6,2")) return "MacBook Pro (15-inch, Mid 2010)"; + if(ffStrEquals(version, "6,1")) return "MacBook Pro (17-inch, Mid 2010)"; + if(ffStrEquals(version, "5,5")) return "MacBook Pro (13-inch, Mid 2009)"; + if(ffStrEquals(version, "5,3")) return "MacBook Pro (15-inch, Mid 2009)"; + if(ffStrEquals(version, "5,2")) return "MacBook Pro (17-inch, Mid/Early 2009)"; + if(ffStrEquals(version, "5,1")) return "MacBook Pro (15-inch, Late 2008)"; + if(ffStrEquals(version, "4,1")) return "MacBook Pro (17/15-inch, Early 2008)"; + } + else if(ffStrbufStartsWithS(hwModel, "MacBookAir")) + { + const char* version = hwModel->chars + strlen("MacBookAir"); + if(ffStrEquals(version, "10,1")) return "MacBook Air (M1, 2020)"; + if(ffStrEquals(version, "9,1")) return "MacBook Air (Retina, 13-inch, 2020)"; + if(ffStrEquals(version, "8,2")) return "MacBook Air (Retina, 13-inch, 2019)"; + if(ffStrEquals(version, "8,1")) return "MacBook Air (Retina, 13-inch, 2018)"; + if(ffStrEquals(version, "7,2")) return "MacBook Air (13-inch, Early 2015/2017)"; + if(ffStrEquals(version, "7,1")) return "MacBook Air (11-inch, Early 2015)"; + if(ffStrEquals(version, "6,2")) return "MacBook Air (13-inch, Mid 2013/Early 2014)"; + if(ffStrEquals(version, "6,1")) return "MacBook Air (11-inch, Mid 2013/Early 2014)"; + if(ffStrEquals(version, "5,2")) return "MacBook Air (13-inch, Mid 2012)"; + if(ffStrEquals(version, "5,1")) return "MacBook Air (11-inch, Mid 2012)"; + if(ffStrEquals(version, "4,2")) return "MacBook Air (13-inch, Mid 2011)"; + if(ffStrEquals(version, "4,1")) return "MacBook Air (11-inch, Mid 2011)"; + if(ffStrEquals(version, "3,2")) return "MacBook Air (13-inch, Late 2010)"; + if(ffStrEquals(version, "3,1")) return "MacBook Air (11-inch, Late 2010)"; + if(ffStrEquals(version, "2,1")) return "MacBook Air (Mid 2009)"; + } + else if(ffStrbufStartsWithS(hwModel, "Macmini")) + { + const char* version = hwModel->chars + strlen("Macmini"); + if(ffStrEquals(version, "9,1")) return "Mac mini (M1, 2020)"; + if(ffStrEquals(version, "8,1")) return "Mac mini (2018)"; + if(ffStrEquals(version, "7,1")) return "Mac mini (Mid 2014)"; + if(ffStrEquals(version, "6,1") || + ffStrEquals(version, "6,2")) return "Mac mini (Late 2012)"; + if(ffStrEquals(version, "5,1") || + ffStrEquals(version, "5,2")) return "Mac mini (Mid 2011)"; + if(ffStrEquals(version, "4,1")) return "Mac mini (Mid 2010)"; + if(ffStrEquals(version, "3,1")) return "Mac mini (Early/Late 2009)"; + } + else if(ffStrbufStartsWithS(hwModel, "MacBook")) + { + const char* version = hwModel->chars + strlen("MacBook"); + if(ffStrEquals(version, "10,1")) return "MacBook (Retina, 12-inch, 2017)"; + if(ffStrEquals(version, "9,1")) return "MacBook (Retina, 12-inch, Early 2016)"; + if(ffStrEquals(version, "8,1")) return "MacBook (Retina, 12-inch, Early 2015)"; + if(ffStrEquals(version, "7,1")) return "MacBook (13-inch, Mid 2010)"; + if(ffStrEquals(version, "6,1")) return "MacBook (13-inch, Late 2009)"; + if(ffStrEquals(version, "5,2")) return "MacBook (13-inch, Early/Mid 2009)"; + } + else if(ffStrbufStartsWithS(hwModel, "MacPro")) + { + const char* version = hwModel->chars + strlen("MacPro"); + if(ffStrEquals(version, "7,1")) return "Mac Pro (2019)"; + if(ffStrEquals(version, "6,1")) return "Mac Pro (Late 2013)"; + if(ffStrEquals(version, "5,1")) return "Mac Pro (Mid 2010 - Mid 2012)"; + if(ffStrEquals(version, "4,1")) return "Mac Pro (Early 2009)"; + } + else if(ffStrbufStartsWithS(hwModel, "Mac")) + { + const char* version = hwModel->chars + strlen("Mac"); + if(ffStrEquals(version, "16,3")) return "iMac (24-inch, 2024, Four Thunderbolt / USB 4 ports)"; + if(ffStrEquals(version, "16,2")) return "iMac (24-inch, 2024, Two Thunderbolt / USB 4 ports)"; + if(ffStrEquals(version, "16,1") || + ffStrEquals(version, "16,6") || + ffStrEquals(version, "16,8")) return "MacBook Pro (14-inch, 2024, Three Thunderbolt 4 ports)"; + if(ffStrEquals(version, "16,7") || + ffStrEquals(version, "16,5")) return "MacBook Pro (16-inch, 2024, Three Thunderbolt 4 ports)"; + if(ffStrEquals(version, "16,15") || + ffStrEquals(version, "16,10")) return "Mac mini (2024)"; + if(ffStrEquals(version, "15,13")) return "MacBook Air (15-inch, M3, 2024)"; + if(ffStrEquals(version, "15,2")) return "MacBook Air (13-inch, M3, 2024)"; + if(ffStrEquals(version, "15,3")) return "MacBook Pro (14-inch, Nov 2023, Two Thunderbolt / USB 4 ports)"; + if(ffStrEquals(version, "15,4")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports)"; + if(ffStrEquals(version, "15,5")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports, Two USB 3 ports)"; + if(ffStrEquals(version, "15,6") || + ffStrEquals(version, "15,8") || + ffStrEquals(version, "15,10")) return "MacBook Pro (14-inch, Nov 2023, Three Thunderbolt 4 ports)"; + if(ffStrEquals(version, "15,7") || + ffStrEquals(version, "15,9") || + ffStrEquals(version, "15,11")) return "MacBook Pro (16-inch, Nov 2023, Three Thunderbolt 4 ports)"; + if(ffStrEquals(version, "14,15")) return "MacBook Air (15-inch, M2, 2023)"; + if(ffStrEquals(version, "14,14")) return "Mac Studio (M2 Ultra, 2023, Two Thunderbolt 4 front ports)"; + if(ffStrEquals(version, "14,13")) return "Mac Studio (M2 Max, 2023, Two USB-C front ports)"; + if(ffStrEquals(version, "14,8")) return "Mac Pro (2023)"; + if(ffStrEquals(version, "14,6") || + ffStrEquals(version, "14,10")) return "MacBook Pro (16-inch, 2023)"; + if(ffStrEquals(version, "14,5") || + ffStrEquals(version, "14,9")) return "MacBook Pro (14-inch, 2023)"; + if(ffStrEquals(version, "14,3")) return "Mac mini (M2, 2023, Two Thunderbolt 4 ports)"; + if(ffStrEquals(version, "14,12")) return "Mac mini (M2, 2023, Four Thunderbolt 4 ports)"; + if(ffStrEquals(version, "14,7")) return "MacBook Pro (13-inch, M2, 2022)"; + if(ffStrEquals(version, "14,2")) return "MacBook Air (M2, 2022)"; + if(ffStrEquals(version, "13,1")) return "Mac Studio (M1 Max, 2022, Two USB-C front ports)"; + if(ffStrEquals(version, "13,2")) return "Mac Studio (M1 Ultra, 2022, Two Thunderbolt 4 front ports)"; + } + else if(ffStrbufStartsWithS(hwModel, "iMac")) + { + const char* version = hwModel->chars + strlen("iMac"); + if(ffStrEquals(version, "21,1")) return "iMac (24-inch, M1, 2021, Two Thunderbolt / USB 4 ports, Two USB 3 ports)"; + if(ffStrEquals(version, "21,2")) return "iMac (24-inch, M1, 2021, Two Thunderbolt / USB 4 ports)"; + if(ffStrEquals(version, "20,1") || + ffStrEquals(version, "20,2")) return "iMac (Retina 5K, 27-inch, 2020)"; + if(ffStrEquals(version, "19,1")) return "iMac (Retina 5K, 27-inch, 2019)"; + if(ffStrEquals(version, "19,2")) return "iMac (Retina 4K, 21.5-inch, 2019)"; + if(ffStrEquals(version, "Pro1,1")) return "iMac Pro (2017)"; + if(ffStrEquals(version, "18,3")) return "iMac (Retina 5K, 27-inch, 2017)"; + if(ffStrEquals(version, "18,2")) return "iMac (Retina 4K, 21.5-inch, 2017)"; + if(ffStrEquals(version, "18,1")) return "iMac (21.5-inch, 2017)"; + if(ffStrEquals(version, "17,1")) return "iMac (Retina 5K, 27-inch, Late 2015)"; + if(ffStrEquals(version, "16,2")) return "iMac (Retina 4K, 21.5-inch, Late 2015)"; + if(ffStrEquals(version, "16,1")) return "iMac (21.5-inch, Late 2015)"; + if(ffStrEquals(version, "15,1")) return "iMac (Retina 5K, 27-inch, Late 2014 - Mid 2015)"; + if(ffStrEquals(version, "14,4")) return "iMac (21.5-inch, Mid 2014)"; + if(ffStrEquals(version, "14,2")) return "iMac (27-inch, Late 2013)"; + if(ffStrEquals(version, "14,1")) return "iMac (21.5-inch, Late 2013)"; + if(ffStrEquals(version, "13,2")) return "iMac (27-inch, Late 2012)"; + if(ffStrEquals(version, "13,1")) return "iMac (21.5-inch, Late 2012)"; + if(ffStrEquals(version, "12,2")) return "iMac (27-inch, Mid 2011)"; + if(ffStrEquals(version, "12,1")) return "iMac (21.5-inch, Mid 2011)"; + if(ffStrEquals(version, "11,3")) return "iMac (27-inch, Mid 2010)"; + if(ffStrEquals(version, "11,2")) return "iMac (21.5-inch, Mid 2010)"; + if(ffStrEquals(version, "10,1")) return "iMac (27/21.5-inch, Late 2009)"; + if(ffStrEquals(version, "9,1")) return "iMac (24/20-inch, Early 2009)"; + } + return NULL; +} + +#ifdef __x86_64__ +bool ffHostDetectMac(FFHostResult* host) +{ + if (ffStrbufEqualS(&host->family, "Mac") && ffStrbufEqualS(&host->vendor, "Apple Inc.")) + { + const char* productName = ffHostGetMacProductNameWithHwModel(&host->name); + if (productName) + { + ffStrbufDestroy(&host->family); + ffStrbufInitMove(&host->family, &host->name); + ffStrbufSetStatic(&host->name, productName); + return true; + } + } + return false; +} +#endif diff --git a/src/detection/host/host_windows.c b/src/detection/host/host_windows.c index c505d9071..bc50d6f08 100644 --- a/src/detection/host/host_windows.c +++ b/src/detection/host/host_windows.c @@ -72,5 +72,9 @@ const char* ffDetectHost(FFHostResult* host) ffCleanUpSmbiosValue(&host->family); } + #if _WIN32 && __x86_64__ + ffHostDetectMac(host); + #endif + return NULL; } diff --git a/src/detection/opengl/opengl_linux.c b/src/detection/opengl/opengl_linux.c index 452d3e6bd..1aaf49f22 100644 --- a/src/detection/opengl/opengl_linux.c +++ b/src/detection/opengl/opengl_linux.c @@ -1,5 +1,6 @@ #include "fastfetch.h" #include "opengl.h" +#include "common/io/io.h" #include @@ -140,6 +141,8 @@ static const char* detectByGlx(FFOpenGLResult* result) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(glx, data, XCloseDisplay); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(glx, data, XFree); + FF_SUPPRESS_IO(); + return glxHandleData(result, &data); } diff --git a/src/detection/opengl/opengl_shared.c b/src/detection/opengl/opengl_shared.c index 66021a227..f13916e74 100644 --- a/src/detection/opengl/opengl_shared.c +++ b/src/detection/opengl/opengl_shared.c @@ -27,7 +27,10 @@ void ffOpenGLHandleResult(FFOpenGLResult* result, __typeof__(&glGetString) ffglG #if defined(FF_HAVE_EGL) || __has_include() #include "common/io/io.h" +#define EGL_EGL_PROTOTYPES 1 +#define EGL_EGLEXT_PROTOTYPES 1 #include +#include typedef struct EGLData { @@ -102,9 +105,20 @@ static const char* eglHandleData(FFOpenGLResult* result, EGLData* data) if(!data->ffglGetString) return "eglGetProcAddress(glGetString) returned NULL"; - data->display = data->ffeglGetDisplay(EGL_DEFAULT_DISPLAY); - if(data->display == EGL_NO_DISPLAY) - return "eglGetDisplay returned EGL_NO_DISPLAY"; + #if EGL_VERSION_1_5 + PFNEGLGETPLATFORMDISPLAYEXTPROC ffeglGetPlatformDisplay = (PFNEGLGETPLATFORMDISPLAYEXTPROC) data->ffeglGetProcAddress("eglGetPlatformDisplay"); + if (ffeglGetPlatformDisplay) + data->display = ffeglGetPlatformDisplay(EGL_PLATFORM_SURFACELESS_MESA, NULL, NULL); + + if(!ffeglGetPlatformDisplay || data->display == EGL_NO_DISPLAY) + #endif + + { + data->display = data->ffeglGetDisplay(EGL_DEFAULT_DISPLAY); + if(data->display == EGL_NO_DISPLAY) + return "eglGetDisplay returned EGL_NO_DISPLAY"; + } + EGLint major, minor; if(data->ffeglInitialize(data->display, &major, &minor) == EGL_FALSE) diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index a00584796..d4ec8b0be 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -52,6 +52,15 @@ FF_MAYBE_UNUSED static void getUbuntuFlavour(FFOSResult* result) if(!ffStrSet(xdgConfigDirs)) return; + if(ffStrbufStartsWithS(&result->prettyName, "Linux Lite ")) + { + ffStrbufSetS(&result->name, "Linux Lite"); + ffStrbufSetS(&result->id, "linuxlite"); + ffStrbufSetS(&result->idLike, "ubuntu"); + ffStrbufSetS(&result->versionID, result->prettyName.chars + strlen("Linux Lite ")); + return; + } + if(ffStrContains(xdgConfigDirs, "kde") || ffStrContains(xdgConfigDirs, "plasma") || ffStrContains(xdgConfigDirs, "kubuntu")) { ffStrbufSetS(&result->name, "Kubuntu"); @@ -166,6 +175,17 @@ FF_MAYBE_UNUSED static bool detectDebianDerived(FFOSResult* result) ffStrbufSetNS(&result->versionID, versionEnd - versionStart, result->prettyName.chars + versionStart); return true; } + else if (ffStrbufStartsWithS(&result->prettyName, "Armbian-unofficial ")) // Unofficial Armbian image built from source + { + ffStrbufSetS(&result->name, "Armbian (custom build)"); + ffStrbufSetS(&result->id, "armbian"); + ffStrbufSetS(&result->idLike, "debian"); + ffStrbufClear(&result->versionID); + uint32_t versionStart = ffStrbufFirstIndexC(&result->prettyName, ' ') + 1; + uint32_t versionEnd = ffStrbufNextIndexC(&result->prettyName, versionStart, ' '); + ffStrbufSetNS(&result->versionID, versionEnd - versionStart, result->prettyName.chars + versionStart); + return true; + } else if (ffStrbufStartsWithS(&result->name, "Loc-OS")) { ffStrbufSetS(&result->id, "locos"); diff --git a/src/detection/wifi/wifi_bsd.c b/src/detection/wifi/wifi_bsd.c index fafc8f1c9..e070b1e50 100644 --- a/src/detection/wifi/wifi_bsd.c +++ b/src/detection/wifi/wifi_bsd.c @@ -37,9 +37,14 @@ const char* ffDetectWifi(FFlist* result) item->conn.channel = 0; item->conn.frequency = 0; + ffParsePropLines(ifconfig.chars, "status: ", &item->conn.status); + if (!ffStrbufEqualS(&item->conn.status, "associated")) + continue; + ffParsePropLines(ifconfig.chars, "ssid ", &item->conn.ssid); if (item->conn.ssid.length) { + // This doesn't work for quoted SSID values uint32_t idx = ffStrbufFirstIndexS(&item->conn.ssid, " bssid "); if (idx < item->conn.ssid.length) { @@ -69,8 +74,6 @@ const char* ffDetectWifi(FFlist* result) ffStrbufPrependS(&item->conn.protocol, "802."); } } - - ffParsePropLines(ifconfig.chars, "status: ", &item->conn.status); } } diff --git a/src/detection/wifi/wifi_linux.c b/src/detection/wifi/wifi_linux.c index 6267db134..b9dafc001 100644 --- a/src/detection/wifi/wifi_linux.c +++ b/src/detection/wifi/wifi_linux.c @@ -285,7 +285,7 @@ static const char* detectWifiWithIoctls(FFWifiResult* item) { for(int i = 0; i < 6; ++i) ffStrbufAppendF(&item->conn.bssid, "%.2X:", (uint8_t) iwr.u.ap_addr.sa_data[i]); - ffStrbufTrimRight(&item->conn.bssid, '-'); + ffStrbufTrimRight(&item->conn.bssid, ':'); } if(ioctl(sock, SIOCGIWRATE, &iwr) >= 0) diff --git a/src/fastfetch.c b/src/fastfetch.c index 07acf68a5..3c8245abe 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -2,6 +2,7 @@ #include "common/commandoption.h" #include "common/io/io.h" #include "common/jsonconfig.h" +#include "common/printing.h" #include "detection/version/version.h" #include "util/stringUtils.h" #include "util/mallocHelper.h" @@ -15,16 +16,65 @@ #include "util/windows/getline.h" #endif +static void printCommandFormatHelpJson(void) +{ + yyjson_mut_doc* doc = yyjson_mut_doc_new(NULL); + yyjson_mut_val* root = yyjson_mut_obj(doc); + yyjson_mut_doc_set_root(doc, root); + + for (uint32_t i = 0; i <= 'Z' - 'A'; ++i) + { + for (FFModuleBaseInfo** modules = ffModuleInfos[i]; *modules; ++modules) + { + FFModuleBaseInfo* baseInfo = *modules; + if (!baseInfo->formatArgs.count) continue; + + FF_STRBUF_AUTO_DESTROY type = ffStrbufCreateS(baseInfo->name); + ffStrbufLowerCase(&type); + ffStrbufAppendS(&type, "Format"); + + yyjson_mut_val* obj = yyjson_mut_obj(doc); + if (yyjson_mut_obj_add(root, yyjson_mut_strbuf(doc, &type), obj)) + { + FF_STRBUF_AUTO_DESTROY content = ffStrbufCreateF("Output format of the module `%s`. See `-h format` for formatting syntax\n", baseInfo->name); + for (unsigned i = 0; i < baseInfo->formatArgs.count; i++) + { + const FFModuleFormatArg* arg = &baseInfo->formatArgs.args[i]; + ffStrbufAppendF(&content, " %u. {%s}: %s\n", i + 1, arg->name, arg->desc); + } + ffStrbufTrimRight(&content, '\n'); + yyjson_mut_obj_add_strbuf(doc, obj, "description", &content); + yyjson_mut_obj_add_str(doc, obj, "type", "string"); + } + } + } + yyjson_mut_write_fp(stdout, doc, YYJSON_WRITE_PRETTY, NULL, NULL); + putchar('\n'); + yyjson_mut_doc_free(doc); +} + static void printCommandFormatHelp(const char* command) { FF_STRBUF_AUTO_DESTROY type = ffStrbufCreateNS((uint32_t) (strlen(command) - strlen("-format")), command); + ffStrbufLowerCase(&type); for (FFModuleBaseInfo** modules = ffModuleInfos[toupper(command[0]) - 'A']; *modules; ++modules) { FFModuleBaseInfo* baseInfo = *modules; if (ffStrbufIgnCaseEqualS(&type, baseInfo->name)) { - if (baseInfo->printHelpFormat) - baseInfo->printHelpFormat(); + if (baseInfo->formatArgs.count > 0) + { + printf("--%s-format:\n", type.chars); + printf("Sets the format string for %s output.\n", baseInfo->name); + puts("To see how a format string is constructed, take a look at \"fastfetch --help format\"."); + puts("The following values are passed:"); + + for (unsigned i = 0; i < baseInfo->formatArgs.count; i++) + { + const FFModuleFormatArg* arg = &baseInfo->formatArgs.args[i]; + printf("%16s {%u}: %s\n", arg->name, i + 1, arg->desc); + } + } else fprintf(stderr, "Error: Module '%s' doesn't support output formatting\n", baseInfo->name); return; @@ -252,6 +302,8 @@ static void printCommandHelp(const char* command) puts(FASTFETCH_DATATEXT_HELP_COLOR); else if(ffStrEqualsIgnCase(command, "format")) puts(FASTFETCH_DATATEXT_HELP_FORMAT); + else if(ffStrEqualsIgnCase(command, "format-json")) + printCommandFormatHelpJson(); else if(ffCharIsEnglishAlphabet(command[0]) && ffStrEndsWithIgnCase(command, "-format")) // -format printCommandFormatHelp(command); else if(!printSpecificCommandHelp(command)) diff --git a/src/logo/ascii/debian.txt b/src/logo/ascii/debian.txt index 6c88f55c8..514bc5a07 100644 --- a/src/logo/ascii/debian.txt +++ b/src/logo/ascii/debian.txt @@ -1,17 +1,17 @@ - $2_,met$$$$$$$$$$gg. - ,g$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$P. - ,g$$$$P" """Y$$$$.". - ,$$$$P' `$$$$$$. + $2_,met$$$$$$$$$$gg. + ,g$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$P. + ,g$$$$P"" """Y$$$$.". + ,$$$$P' `$$$$$$. ',$$$$P ,ggs. `$$$$b: `d$$$$' ,$P"' $1.$2 $$$$$$ - $$$$P d$' $1,$2 $$$$$$P - $$$$: $$. $1-$2 ,d$$$$' + $$$$P d$' $1,$2 $$$$P + $$$$: $$$. $1-$2 ,d$$$$' $$$$; Y$b._ _,d$P' Y$$$$. $1`.$2`"Y$$$$$$$$P"' `$$$$b $1"-.__ - $2`Y$$$$ + $2`Y$$$$b `Y$$$$. `$$$$b. `Y$$$$b. - `"Y$$b._ - `""" \ No newline at end of file + `"Y$$b._ + `"""" \ No newline at end of file diff --git a/src/logo/ascii/linuxlite.txt b/src/logo/ascii/linuxlite.txt index 0782d8d77..eb5185aec 100644 --- a/src/logo/ascii/linuxlite.txt +++ b/src/logo/ascii/linuxlite.txt @@ -1,20 +1,20 @@ ,xXc .l0MMMMMO - .kNMMMMMWMMMN, - KMMMMMMKMMMMMMo - 'MMMMMMNKMMMMMM: - kMMMMMMOMMMMMMO - .MMMMMMX0MMMMMW. - oMMMMMMxWMMMMM: - WMMMMMNkMMMMMO -:MMMMMMOXMMMMW -.0MMMMMxMMMMM; -:;cKMMWxMMMMO -'MMWMMXOMMMMl - kMMMMKOMMMMMX: - .WMMMMKOWMMM0c - lMMMMMWO0MNd:' - oollXMKXoxl;. - ':. .: .' - .. + .kNMMMMM$2W$1MMMN, + KMMMMMM$2K$1MMMMMMo + 'MMMMMMN$2K$1MMMMMM: + kMMMMMM$2O$1MMMMMMO + .MMMMMM$20$1XMMMMMW. + oMMMMM$2x$1MMMMMMM: + WMMMMM$2x$1MMMMMMO +:MMMMMM$2O$1XMMMMW +.0MMMMM$2x$1MMMMM; +:;cKMMW$2x$1MMMMO +'MMWMMX$2O$1MMMMl + kMMMMK$2O$1MMMMMX: + .WMMMMK$2O$1WMMM0c + lMMMMMW$2O$1WMNd:' + oollXMK$2o$1Xxl;. + ':. .:$2 .$1' + $2.. . \ No newline at end of file diff --git a/src/logo/ascii/linuxlite_small.txt b/src/logo/ascii/linuxlite_small.txt index 26afafb9f..4c29f71b4 100644 --- a/src/logo/ascii/linuxlite_small.txt +++ b/src/logo/ascii/linuxlite_small.txt @@ -1,7 +1,7 @@ -${c1} /\\ - / \\ - / ${c2}/ ${c1}/ -> ${c2}/ ${c1}/ + /\\ + / \\ + / ${c2}/ ${c1}/ + > ${c2}/ ${c1}/ \\ ${c2}\\ ${c1}\\ \\_${c2}\\${c1}_\\ -${c2} \\ \ No newline at end of file +${c2} \\ \ No newline at end of file diff --git a/src/logo/ascii/serpent_os.txt b/src/logo/ascii/serpent_os.txt new file mode 100644 index 000000000..e09d617ce --- /dev/null +++ b/src/logo/ascii/serpent_os.txt @@ -0,0 +1,18 @@ + ,dKNWWNKOxo;. + ;xKXOdoloOWMWX0d:. + .dNNd' cNMMMMNKOx;. + .dWNo .:oxO000KXKl. + .OMNl ..... + oNMXd,. + .lKWMNKkdollccc:::;;;,'.. + .;ox0KNWWMMMMMMMMWWWWNK0xl,. + ..,;:ccloodxO0KNWMMMMNOc. + .';lxKWMMWk' + ..,:ccc:,. .oXMMMO + .:d0NWWWWWMWXOo,. .,cc:;,,'..oWMMW + .c0WW0xl:;,;cd0NMNO:'..ldl;. .'.:XMMM + xWMKc. .;OWMWX0xl. .dWMMK + WMWd. .oKWMMXx, .dNMMXc + NMMK:. ..:oxo:oOXMMNOdc:;;cxKWMWO; + ;kXWN0xooodkOOko;. .lONMMMMWWMMWKx;. + ,okKXXXKOxc'. .:kKWMMWXOl' diff --git a/src/logo/ascii/ultramarine_small.txt b/src/logo/ascii/ultramarine_small.txt new file mode 100644 index 000000000..a9d93c676 --- /dev/null +++ b/src/logo/ascii/ultramarine_small.txt @@ -0,0 +1,14 @@ + @@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@@@@ +@@@@@@@@@@@@@@@@@@@@@@@@@@ +@@@@@@@@@*=+*%@@@@@@@@@@@@ +@@@@@@@@@@: :#@@@@@@@@@@ +@@@@@@@@@# -#@@@@@@@@ +@@%###*=. :=*#@@@@ +@@= =@@ + @@= -@@ + @@*: :*@@ + @%*=: :=*@@ + @@@%%##%%@@@ diff --git a/src/logo/builtin.c b/src/logo/builtin.c index c0e867009..a8271d6f5 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -2477,10 +2477,10 @@ static const FFlogo L[] = { .names = {"LinuxLite", "Linux Lite", "linux_lite"}, .lines = FASTFETCH_DATATEXT_LOGO_LINUXLITE, .colors = { - FF_COLOR_FG_YELLOW, + FF_COLOR_FG_GREEN, FF_COLOR_FG_WHITE, }, - .colorKeys = FF_COLOR_FG_YELLOW, + .colorKeys = FF_COLOR_FG_GREEN, .colorTitle = FF_COLOR_FG_WHITE, }, // LinuxLightSmall @@ -2489,10 +2489,10 @@ static const FFlogo L[] = { .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_LINUXLITE_SMALL, .colors = { - FF_COLOR_FG_YELLOW, + FF_COLOR_FG_BLUE, FF_COLOR_FG_WHITE, }, - .colorKeys = FF_COLOR_FG_YELLOW, + .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_WHITE, }, // LinuxMint @@ -4052,6 +4052,14 @@ static const FFlogo S[] = { FF_COLOR_FG_RED, }, }, + // Serpent OS + { + .names = {"Serpent OS"}, + .lines = FASTFETCH_DATATEXT_LOGO_SERPENT_OS, + .colors = { + FF_COLOR_FG_WHITE, + }, + }, // Semc { .names = {"semc"}, @@ -4627,6 +4635,15 @@ static const FFlogo U[] = { FF_COLOR_FG_WHITE, }, }, + // Ultramarine Small + { + .names = {"Ultramarine_small"}, + .lines = FASTFETCH_DATATEXT_LOGO_ULTRAMARINE_SMALL, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, // Unifi { .names = {"Unifi"}, diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index c40f7a629..5dd95c11c 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -7,8 +7,6 @@ #include "modules/battery/battery.h" #include "util/stringUtils.h" -#define FF_BATTERY_NUM_FORMAT_ARGS 14 - static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uint8_t index) { FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); @@ -22,7 +20,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin else { ffStrbufClear(&key); - FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 2, ((FFformatarg[]){ + FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) { FF_FORMAT_ARG(index, "index"), FF_FORMAT_ARG(result->modelName, "name"), })); @@ -105,7 +103,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate(); ffTempsAppendNum(result->temperature, &tempStr, options->tempConfig, &options->moduleArgs); - FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BATTERY_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) { FF_FORMAT_ARG(result->manufacturer, "manufacturer"), FF_FORMAT_ARG(result->modelName, "model-name"), FF_FORMAT_ARG(result->technology, "technology"), @@ -270,39 +268,35 @@ void ffGenerateBatteryJsonResult(FFBatteryOptions* options, yyjson_mut_doc* doc, } } -void ffPrintBatteryHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BATTERY_MODULE_NAME, "{4} ({12} hours {13} mins) [{5}]", FF_BATTERY_NUM_FORMAT_ARGS, ((const char* []) { - "Battery manufacturer - manufacturer", - "Battery model name - model-name", - "Battery technology - technology", - "Battery capacity (percentage num) - capacity", - "Battery status - status", - "Battery temperature (formatted) - temperature", - "Battery cycle count - cycle-count", - "Battery serial number - serial", - "Battery manufactor date - manufacture-date", - "Battery capacity (percentage bar) - capacity-bar", - "Battery time remaining days - time-days", - "Battery time remaining hours - time-hours", - "Battery time remaining minutes - time-minutes", - "Battery time remaining seconds - time-seconds", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_BATTERY_MODULE_NAME, + .description = "Print battery capacity, status, etc", + .parseCommandOptions = (void*) ffParseBatteryCommandOptions, + .parseJsonObject = (void*) ffParseBatteryJsonObject, + .printModule = (void*) ffPrintBattery, + .generateJsonResult = (void*) ffGenerateBatteryJsonResult, + .generateJsonConfig = (void*) ffGenerateBatteryJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Battery manufacturer", "manufacturer"}, + {"Battery model name", "model-name"}, + {"Battery technology", "technology"}, + {"Battery capacity (percentage num)", "capacity"}, + {"Battery status", "status"}, + {"Battery temperature (formatted)", "temperature"}, + {"Battery cycle count", "cycle-count"}, + {"Battery serial number", "serial"}, + {"Battery manufactor date", "manufacture-date"}, + {"Battery capacity (percentage bar)", "capacity-bar"}, + {"Battery time remaining days", "time-days"}, + {"Battery time remaining hours", "time-hours"}, + {"Battery time remaining minutes", "time-minutes"}, + {"Battery time remaining seconds", "time-seconds"}, + })) +}; void ffInitBatteryOptions(FFBatteryOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_BATTERY_MODULE_NAME, - "Print battery capacity, status, etc", - ffParseBatteryCommandOptions, - ffParseBatteryJsonObject, - ffPrintBattery, - ffGenerateBatteryJsonResult, - ffPrintBatteryHelpFormat, - ffGenerateBatteryJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); options->temp = false; options->tempConfig = (FFColorRangeConfig) { 60, 80 }; diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index 6e4e81dd4..a5363eebf 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -4,8 +4,6 @@ #include "modules/bios/bios.h" #include "util/stringUtils.h" -#define FF_BIOS_NUM_FORMAT_ARGS 5 - void ffPrintBios(FFBiosOptions* options) { FFBiosResult bios; @@ -43,7 +41,7 @@ void ffPrintBios(FFBiosOptions* options) else { ffStrbufClear(&key); - FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 2, ((FFformatarg[]){ + FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) { FF_FORMAT_ARG(bios.type, "type"), FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), })); @@ -60,7 +58,7 @@ void ffPrintBios(FFBiosOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BIOS_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) { FF_FORMAT_ARG(bios.date, "date"), FF_FORMAT_ARG(bios.release, "release"), FF_FORMAT_ARG(bios.vendor, "vendor"), @@ -144,30 +142,26 @@ void ffGenerateBiosJsonResult(FF_MAYBE_UNUSED FFBiosOptions* options, yyjson_mut ffStrbufDestroy(&bios.type); } -void ffPrintBiosHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BIOS_MODULE_NAME, "{4} ({2})", FF_BIOS_NUM_FORMAT_ARGS, ((const char* []) { - "bios date - date", - "bios release - release", - "bios vendor - vendor", - "bios version - version", - "firmware type - type", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_BIOS_MODULE_NAME, + .description = "Print information of 1st-stage bootloader (name, version, release date, etc)", + .parseCommandOptions = (void*) ffParseBiosCommandOptions, + .parseJsonObject = (void*) ffParseBiosJsonObject, + .printModule = (void*) ffPrintBios, + .generateJsonResult = (void*) ffGenerateBiosJsonResult, + .generateJsonConfig = (void*) ffGenerateBiosJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Bios date", "date"}, + {"Bios release", "release"}, + {"Bios vendor", "vendor"}, + {"Bios version", "version"}, + {"Firmware type", "type"}, + })) +}; void ffInitBiosOptions(FFBiosOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_BIOS_MODULE_NAME, - "Print information of 1st-stage bootloader (name, version, release date, etc)", - ffParseBiosCommandOptions, - ffParseBiosJsonObject, - ffPrintBios, - ffGenerateBiosJsonResult, - ffPrintBiosHelpFormat, - ffGenerateBiosJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index 0116ce236..fe3357d4f 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -5,8 +5,6 @@ #include "modules/bluetooth/bluetooth.h" #include "util/stringUtils.h" -#define FF_BLUETOOTH_NUM_FORMAT_ARGS 6 - static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* device, uint8_t index) { FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type; @@ -47,7 +45,7 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* de if(percentType & FF_PERCENTAGE_TYPE_BAR_BIT) ffPercentAppendBar(&percentageBar, device->battery, options->percent, &options->moduleArgs); - FF_PRINT_FORMAT_CHECKED(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BLUETOOTH_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(device->name, "name"), FF_FORMAT_ARG(device->address, "address"), FF_FORMAT_ARG(device->type, "type"), @@ -188,31 +186,27 @@ void ffGenerateBluetoothJsonResult(FF_MAYBE_UNUSED FFBluetoothOptions* options, } } -void ffPrintBluetoothHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BLUETOOTH_MODULE_NAME, "{1} ({4})", FF_BLUETOOTH_NUM_FORMAT_ARGS, ((const char* []) { - "Name - device name", - "Address - remote device address", - "Type - type", - "Battery percentage number - battery-percentage", - "Is connected - connected", - "Battery percentage bar - battery-percentage-bar", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_BLUETOOTH_MODULE_NAME, + .description = "List (connected) bluetooth devices", + .parseCommandOptions = (void*) ffParseBluetoothCommandOptions, + .parseJsonObject = (void*) ffParseBluetoothJsonObject, + .printModule = (void*) ffPrintBluetooth, + .generateJsonResult = (void*) ffGenerateBluetoothJsonResult, + .generateJsonConfig = (void*) ffGenerateBluetoothJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Name", "name"}, + {"Address", "address"}, + {"Type", "type"}, + {"Battery percentage number", "battery-percentage"}, + {"Is connected", "connected"}, + {"Battery percentage bar", "battery-percentage-bar"}, + })) +}; void ffInitBluetoothOptions(FFBluetoothOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_BLUETOOTH_MODULE_NAME, - "List (connected) bluetooth devices", - ffParseBluetoothCommandOptions, - ffParseBluetoothJsonObject, - ffPrintBluetooth, - ffGenerateBluetoothJsonResult, - ffPrintBluetoothHelpFormat, - ffGenerateBluetoothJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); options->showDisconnected = false; options->percent = (FFPercentageModuleConfig) { 50, 20, 0 }; diff --git a/src/modules/bluetoothradio/bluetoothradio.c b/src/modules/bluetoothradio/bluetoothradio.c index 8782c4aca..f5bd940c8 100644 --- a/src/modules/bluetoothradio/bluetoothradio.c +++ b/src/modules/bluetoothradio/bluetoothradio.c @@ -5,7 +5,6 @@ #include "modules/bluetoothradio/bluetoothradio.h" #include "util/stringUtils.h" -#define FF_BLUETOOTHRADIO_NUM_FORMAT_ARGS 8 #define FF_BLUETOOTHRADIO_DISPLAY_NAME "Bluetooth Radio" static void printDevice(FFBluetoothRadioOptions* options, const FFBluetoothRadioResult* radio, uint8_t index) @@ -17,7 +16,7 @@ static void printDevice(FFBluetoothRadioOptions* options, const FFBluetoothRadio } else { - FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){ + FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) { FF_FORMAT_ARG(index, "index"), FF_FORMAT_ARG(radio->name, "name"), FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), @@ -55,7 +54,7 @@ static void printDevice(FFBluetoothRadioOptions* options, const FFBluetoothRadio } else { - FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BLUETOOTHRADIO_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) { FF_FORMAT_ARG(radio->name, "name"), FF_FORMAT_ARG(radio->address, "address"), FF_FORMAT_ARG(radio->lmpVersion, "lmp-version"), @@ -181,33 +180,29 @@ void ffGenerateBluetoothRadioJsonResult(FF_MAYBE_UNUSED FFBluetoothRadioOptions* } } -void ffPrintBluetoothRadioHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BLUETOOTHRADIO_MODULE_NAME, "Bluetooth {5} ({6})", FF_BLUETOOTHRADIO_NUM_FORMAT_ARGS, ((const char* []) { - "Radio name for discovering - name", - "Address - local radio address", - "LMP version - lmp-version", - "LMP subversion - lmp-subversion", - "Bluetooth version - version", - "Vendor - vendor", - "Discoverable - discoverable", - "Connectable / Pairable - connectable", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_BLUETOOTHRADIO_MODULE_NAME, + .description = "List bluetooth radios width supported version and vendor", + .parseCommandOptions = (void*) ffParseBluetoothRadioCommandOptions, + .parseJsonObject = (void*) ffParseBluetoothRadioJsonObject, + .printModule = (void*) ffPrintBluetoothRadio, + .generateJsonResult = (void*) ffGenerateBluetoothRadioJsonResult, + .generateJsonConfig = (void*) ffGenerateBluetoothRadioJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Radio name for discovering", "name"}, + {"Address", "address"}, + {"LMP version", "lmp-version"}, + {"LMP subversion", "lmp-subversion"}, + {"Bluetooth version", "version"}, + {"Vendor", "vendor"}, + {"Discoverable", "discoverable"}, + {"Connectable / Pairable", "connectable"}, + })) +}; void ffInitBluetoothRadioOptions(FFBluetoothRadioOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_BLUETOOTHRADIO_MODULE_NAME, - "List bluetooth radios width supported version and vendor", - ffParseBluetoothRadioCommandOptions, - ffParseBluetoothRadioJsonObject, - ffPrintBluetoothRadio, - ffGenerateBluetoothRadioJsonResult, - ffPrintBluetoothRadioHelpFormat, - ffGenerateBluetoothRadioJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰐻"); } diff --git a/src/modules/board/board.c b/src/modules/board/board.c index 58d841b0e..f499446c8 100644 --- a/src/modules/board/board.c +++ b/src/modules/board/board.c @@ -4,8 +4,6 @@ #include "modules/board/board.h" #include "util/stringUtils.h" -#define FF_BOARD_NUM_FORMAT_ARGS 4 - void ffPrintBoard(FFBoardOptions* options) { FFBoardResult result; @@ -37,7 +35,7 @@ void ffPrintBoard(FFBoardOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BOARD_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(result.name, "name"), FF_FORMAT_ARG(result.vendor, "vendor"), FF_FORMAT_ARG(result.version, "version"), @@ -122,29 +120,25 @@ void ffGenerateBoardJsonResult(FF_MAYBE_UNUSED FFBoardOptions* options, yyjson_m ffStrbufDestroy(&board.serial); } -void ffPrintBoardHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BOARD_MODULE_NAME, "{1} ({3})", FF_BOARD_NUM_FORMAT_ARGS, ((const char* []) { - "board name - name", - "board vendor - vendor", - "board version - version", - "board serial number - serial", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_BOARD_MODULE_NAME, + .description = "Print motherboard name and other info", + .parseCommandOptions = (void*) ffParseBoardCommandOptions, + .parseJsonObject = (void*) ffParseBoardJsonObject, + .printModule = (void*) ffPrintBoard, + .generateJsonResult = (void*) ffGenerateBoardJsonResult, + .generateJsonConfig = (void*) ffGenerateBoardJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Board name", "name"}, + {"Board vendor", "vendor"}, + {"Board version", "version"}, + {"Board serial number", "serial"}, + })) +}; void ffInitBoardOptions(FFBoardOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_BOARD_MODULE_NAME, - "Print motherboard name and other info", - ffParseBoardCommandOptions, - ffParseBoardJsonObject, - ffPrintBoard, - ffGenerateBoardJsonResult, - ffPrintBoardHelpFormat, - ffGenerateBoardJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/bootmgr/bootmgr.c b/src/modules/bootmgr/bootmgr.c index 960da0e43..70e081e00 100644 --- a/src/modules/bootmgr/bootmgr.c +++ b/src/modules/bootmgr/bootmgr.c @@ -4,8 +4,6 @@ #include "modules/bootmgr/bootmgr.h" #include "util/stringUtils.h" -#define FF_BOOTMGR_NUM_FORMAT_ARGS 4 - void ffPrintBootmgr(FFBootmgrOptions* options) { FFBootmgrResult bootmgr = { @@ -39,7 +37,7 @@ void ffPrintBootmgr(FFBootmgrOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_BOOTMGR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BOOTMGR_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_BOOTMGR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(bootmgr.name, "name"), FF_FORMAT_ARG(bootmgr.firmware, "firmware-path"), FF_FORMAT_ARG(firmwareName, "firmware-name"), @@ -111,29 +109,25 @@ void ffGenerateBootmgrJsonResult(FF_MAYBE_UNUSED FFBootmgrOptions* options, yyjs ffStrbufDestroy(&bootmgr.firmware); } -void ffPrintBootmgrHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BOOTMGR_MODULE_NAME, "{4} ({2})", FF_BOOTMGR_NUM_FORMAT_ARGS, ((const char* []) { - "Name / description - name", - "Firmware file path - firmware-path", - "Firmware file name - firmware-name", - "Is secure boot enabled - secure-boot", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_BOOTMGR_MODULE_NAME, + .description = "Print information of 2nd-stage bootloader (name, firmware, etc)", + .parseCommandOptions = (void*) ffParseBootmgrCommandOptions, + .parseJsonObject = (void*) ffParseBootmgrJsonObject, + .printModule = (void*) ffPrintBootmgr, + .generateJsonResult = (void*) ffGenerateBootmgrJsonResult, + .generateJsonConfig = (void*) ffGenerateBootmgrJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Name / description", "name"}, + {"Firmware file path", "firmware-path"}, + {"Firmware file name", "firmware-name"}, + {"Is secure boot enabled", "secure-boot"}, + })) +}; void ffInitBootmgrOptions(FFBootmgrOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_BOOTMGR_MODULE_NAME, - "Print information of 2nd-stage bootloader (name, firmware, etc)", - ffParseBootmgrCommandOptions, - ffParseBootmgrJsonObject, - ffPrintBootmgr, - ffGenerateBootmgrJsonResult, - ffPrintBootmgrHelpFormat, - ffGenerateBootmgrJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/break/break.c b/src/modules/break/break.c index 9b02d181a..89228e4f4 100644 --- a/src/modules/break/break.c +++ b/src/modules/break/break.c @@ -16,19 +16,17 @@ void ffParseBreakJsonObject(FF_MAYBE_UNUSED FFBreakOptions* options, FF_MAYBE_UN { } +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_BREAK_MODULE_NAME, + .description = "Print a empty line", + .parseCommandOptions = (void*) ffParseBreakCommandOptions, + .parseJsonObject = (void*) ffParseBreakJsonObject, + .printModule = (void*) ffPrintBreak, +}; + void ffInitBreakOptions(FF_MAYBE_UNUSED FFBreakOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_BREAK_MODULE_NAME, - "Print a empty line", - ffParseBreakCommandOptions, - ffParseBreakJsonObject, - ffPrintBreak, - NULL, - NULL, - NULL - ); + options->moduleInfo = ffModuleInfo; } void ffDestroyBreakOptions(FF_MAYBE_UNUSED FFBreakOptions* options) diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index dc7e2f455..e4862f526 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -5,8 +5,6 @@ #include "modules/brightness/brightness.h" #include "util/stringUtils.h" -#define FF_BRIGHTNESS_NUM_FORMAT_ARGS 6 - void ffPrintBrightness(FFBrightnessOptions* options) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFBrightnessResult)); @@ -57,7 +55,7 @@ void ffPrintBrightness(FFBrightnessOptions* options) else { uint32_t moduleIndex = result.length == 1 ? 0 : index + 1; - FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){ + FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) { FF_FORMAT_ARG(moduleIndex, "index"), FF_FORMAT_ARG(item->name, "name"), FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), @@ -95,7 +93,7 @@ void ffPrintBrightness(FFBrightnessOptions* options) if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) ffPercentAppendBar(&valueBar, percent, options->percent, &options->moduleArgs); - FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BRIGHTNESS_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) { FF_FORMAT_ARG(valueNum, "percentage"), FF_FORMAT_ARG(item->name, "name"), FF_FORMAT_ARG(item->max, "max"), @@ -214,31 +212,27 @@ void ffGenerateBrightnessJsonResult(FF_MAYBE_UNUSED FFBrightnessOptions* options } } -void ffPrintBrightnessHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BRIGHTNESS_MODULE_NAME, "{1}", FF_BRIGHTNESS_NUM_FORMAT_ARGS, ((const char* []) { - "Screen brightness (percentage num) - percentage", - "Screen name - name", - "Maximum brightness value - max", - "Minimum brightness value - min", - "Current brightness value - current", - "Screen brightness (percentage bar) - percentage-bar", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_BRIGHTNESS_MODULE_NAME, + .description = "Print current brightness level of your monitors", + .parseCommandOptions = (void*) ffParseBrightnessCommandOptions, + .parseJsonObject = (void*) ffParseBrightnessJsonObject, + .printModule = (void*) ffPrintBrightness, + .generateJsonResult = (void*) ffGenerateBrightnessJsonResult, + .generateJsonConfig = (void*) ffGenerateBrightnessJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Screen brightness (percentage num)", "percentage"}, + {"Screen name", "name"}, + {"Maximum brightness value", "max"}, + {"Minimum brightness value", "min"}, + {"Current brightness value", "current"}, + {"Screen brightness (percentage bar)", "percentage-bar"}, + })) +}; void ffInitBrightnessOptions(FFBrightnessOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_BRIGHTNESS_MODULE_NAME, - "Print current brightness level of your monitors", - ffParseBrightnessCommandOptions, - ffParseBrightnessJsonObject, - ffPrintBrightness, - ffGenerateBrightnessJsonResult, - ffPrintBrightnessHelpFormat, - ffGenerateBrightnessJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰯪"); options->ddcciSleep = 10; diff --git a/src/modules/btrfs/btrfs.c b/src/modules/btrfs/btrfs.c index e295a2a26..6d6f1a7dc 100644 --- a/src/modules/btrfs/btrfs.c +++ b/src/modules/btrfs/btrfs.c @@ -5,8 +5,6 @@ #include "modules/btrfs/btrfs.h" #include "util/stringUtils.h" -#define FF_BTRFS_NUM_FORMAT_ARGS 13 - static void printBtrfs(FFBtrfsOptions* options, FFBtrfsResult* result, uint8_t index) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); @@ -20,7 +18,7 @@ static void printBtrfs(FFBtrfsOptions* options, FFBtrfsResult* result, uint8_t i else { ffStrbufClear(&buffer); - FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, 3, ((FFformatarg[]){ + FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, ((FFformatarg[]) { FF_FORMAT_ARG(index, "index"), FF_FORMAT_ARG(result->name, "name"), FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), @@ -80,7 +78,7 @@ static void printBtrfs(FFBtrfsOptions* options, FFBtrfsResult* result, uint8_t i FF_STRBUF_AUTO_DESTROY sectorSizePretty = ffStrbufCreate(); ffParseSize(result->sectorSize, §orSizePretty); - FF_PRINT_FORMAT_CHECKED(buffer.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BTRFS_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(buffer.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) { FF_FORMAT_ARG(result->name, "name"), FF_FORMAT_ARG(result->uuid, "uuid"), FF_FORMAT_ARG(result->devices, "devices"), @@ -218,38 +216,34 @@ void ffGenerateBtrfsJsonResult(FF_MAYBE_UNUSED FFBtrfsOptions* options, yyjson_m } } -void ffPrintBtrfsHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BTRFS_MODULE_NAME, "{5} / {7} ({8}, {9} allocated)", FF_BTRFS_NUM_FORMAT_ARGS, ((const char* []) { - "Name / Label - name", - "UUID - uuid", - "Associated devices - devices", - "Enabled features - features", - "Size used - used", - "Size allocated - allocated", - "Size total - total", - "Used percentage num - used-percentage", - "Allocated percentage num - allocated-percentage", - "Used percentage bar - used-percentage-bar", - "Allocated percentage bar - allocated-percentage-bar", - "Node size - node-size", - "Sector size - sector-size", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_BTRFS_MODULE_NAME, + .description = "Print Linux BTRFS volumes", + .parseCommandOptions = (void*) ffParseBtrfsCommandOptions, + .parseJsonObject = (void*) ffParseBtrfsJsonObject, + .printModule = (void*) ffPrintBtrfs, + .generateJsonResult = (void*) ffGenerateBtrfsJsonResult, + .generateJsonConfig = (void*) ffGenerateBtrfsJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Name / Label", "name"}, + {"UUID", "uuid"}, + {"Associated devices", "devices"}, + {"Enabled features", "features"}, + {"Size used", "used"}, + {"Size allocated", "allocated"}, + {"Size total", "total"}, + {"Used percentage num", "used-percentage"}, + {"Allocated percentage num", "allocated-percentage"}, + {"Used percentage bar", "used-percentage-bar"}, + {"Allocated percentage bar", "allocated-percentage-bar"}, + {"Node size", "node-size"}, + {"Sector size", "sector-size"}, + })) +}; void ffInitBtrfsOptions(FFBtrfsOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_BTRFS_MODULE_NAME, - "Print BTRFS volumes", - ffParseBtrfsCommandOptions, - ffParseBtrfsJsonObject, - ffPrintBtrfs, - ffGenerateBtrfsJsonResult, - ffPrintBtrfsHelpFormat, - ffGenerateBtrfsJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󱑛"); options->percent = (FFPercentageModuleConfig) { 50, 80, 0 }; } diff --git a/src/modules/camera/camera.c b/src/modules/camera/camera.c index 4615dc7e1..26ef4b3ce 100644 --- a/src/modules/camera/camera.c +++ b/src/modules/camera/camera.c @@ -5,8 +5,6 @@ #include "modules/camera/camera.h" #include "util/stringUtils.h" -#define FF_CAMERA_NUM_FORMAT_ARGS 6 - static void printDevice(FFCameraOptions* options, const FFCameraResult* device, uint8_t index) { if(options->moduleArgs.outputFormat.length == 0) @@ -27,7 +25,7 @@ static void printDevice(FFCameraOptions* options, const FFCameraResult* device, } else { - FF_PRINT_FORMAT_CHECKED(FF_CAMERA_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CAMERA_NUM_FORMAT_ARGS, (((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_CAMERA_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, (((FFformatarg[]) { FF_FORMAT_ARG(device->name, "name"), FF_FORMAT_ARG(device->vendor, "vendor"), FF_FORMAT_ARG(device->colorspace, "colorspace"), @@ -136,31 +134,27 @@ void ffGenerateCameraJsonResult(FF_MAYBE_UNUSED FFCameraOptions* options, yyjson } } -void ffPrintCameraHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CAMERA_MODULE_NAME, "{1} ({4}px x {5}px)", FF_CAMERA_NUM_FORMAT_ARGS, ((const char* []) { - "Device name - name", - "Vendor - vendor", - "Color space - colorspace", - "Identifier - id", - "Width (in px) - width", - "Height (in px) - height", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_CAMERA_MODULE_NAME, + .description = "Print available cameras", + .parseCommandOptions = (void*) ffParseCameraCommandOptions, + .parseJsonObject = (void*) ffParseCameraJsonObject, + .printModule = (void*) ffPrintCamera, + .generateJsonResult = (void*) ffGenerateCameraJsonResult, + .generateJsonConfig = (void*) ffGenerateCameraJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Device name", "name"}, + {"Vendor", "vendor"}, + {"Color space", "colorspace"}, + {"Identifier", "id"}, + {"Width (in px)", "width"}, + {"Height (in px)", "height"}, + })) +}; void ffInitCameraOptions(FFCameraOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_CAMERA_MODULE_NAME, - "Print available cameras", - ffParseCameraCommandOptions, - ffParseCameraJsonObject, - ffPrintCamera, - ffGenerateCameraJsonResult, - ffPrintCameraHelpFormat, - ffGenerateCameraJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰄀"); } diff --git a/src/modules/chassis/chassis.c b/src/modules/chassis/chassis.c index d87b4ad46..16805a52a 100644 --- a/src/modules/chassis/chassis.c +++ b/src/modules/chassis/chassis.c @@ -4,8 +4,6 @@ #include "modules/chassis/chassis.h" #include "util/stringUtils.h" -#define FF_CHASSIS_NUM_FORMAT_ARGS 4 - void ffPrintChassis(FFChassisOptions* options) { FFChassisResult result; @@ -38,7 +36,7 @@ void ffPrintChassis(FFChassisOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CHASSIS_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(result.type, "type"), FF_FORMAT_ARG(result.vendor, "vendor"), FF_FORMAT_ARG(result.version, "version"), @@ -123,29 +121,25 @@ void ffGenerateChassisJsonResult(FF_MAYBE_UNUSED FFChassisOptions* options, yyjs ffStrbufDestroy(&result.serial); } -void ffPrintChassisHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CHASSIS_MODULE_NAME, "{1}", FF_CHASSIS_NUM_FORMAT_ARGS, ((const char* []) { - "chassis type - type", - "chassis vendor - vendor", - "chassis version - version", - "chassis serial number - serial", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_CHASSIS_MODULE_NAME, + .description = "Print chassis type (desktop, laptop, etc)", + .parseCommandOptions = (void*) ffParseChassisCommandOptions, + .parseJsonObject = (void*) ffParseChassisJsonObject, + .printModule = (void*) ffPrintChassis, + .generateJsonResult = (void*) ffGenerateChassisJsonResult, + .generateJsonConfig = (void*) ffGenerateChassisJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Chassis type", "type"}, + {"Chassis vendor", "vendor"}, + {"Chassis version", "version"}, + {"Chassis serial number", "serial"}, + })), +}; void ffInitChassisOptions(FFChassisOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_CHASSIS_MODULE_NAME, - "Print chassis type (desktop, laptop, etc)", - ffParseChassisCommandOptions, - ffParseChassisJsonObject, - ffPrintChassis, - ffGenerateChassisJsonResult, - ffPrintChassisHelpFormat, - ffGenerateChassisJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/colors/colors.c b/src/modules/colors/colors.c index 7da162136..038bb5cc1 100644 --- a/src/modules/colors/colors.c +++ b/src/modules/colors/colors.c @@ -291,19 +291,18 @@ void ffGenerateColorsJsonConfig(FFColorsOptions* options, yyjson_mut_doc* doc, y } } +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_COLORS_MODULE_NAME, + .description = "Print some colored blocks", + .parseCommandOptions = (void*) ffParseColorsCommandOptions, + .parseJsonObject = (void*) ffParseColorsJsonObject, + .printModule = (void*) ffPrintColors, + .generateJsonConfig = (void*) ffGenerateColorsJsonConfig, +}; + void ffInitColorsOptions(FFColorsOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_COLORS_MODULE_NAME, - "Print some colored blocks", - ffParseColorsCommandOptions, - ffParseColorsJsonObject, - ffPrintColors, - NULL, - NULL, - ffGenerateColorsJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); ffStrbufSetStatic(&options->moduleArgs.key, " "); options->symbol = FF_COLORS_SYMBOL_BACKGROUND; diff --git a/src/modules/command/command.c b/src/modules/command/command.c index 0db07b4bd..7f5a28365 100644 --- a/src/modules/command/command.c +++ b/src/modules/command/command.c @@ -4,8 +4,6 @@ #include "modules/command/command.h" #include "util/stringUtils.h" -#define FF_COMMAND_NUM_FORMAT_ARGS 1 - void ffPrintCommand(FFCommandOptions* options) { FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate(); @@ -39,7 +37,7 @@ void ffPrintCommand(FFCommandOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_COMMAND_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(result, "result") })); } @@ -154,26 +152,22 @@ void ffGenerateCommandJsonResult(FF_MAYBE_UNUSED FFCommandOptions* options, yyjs yyjson_mut_obj_add_strbuf(doc, module, "result", &result); } -void ffPrintCommandHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_COMMAND_MODULE_NAME, "{1}", FF_COMMAND_NUM_FORMAT_ARGS, ((const char* []) { - "Command result - result" - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_COMMAND_MODULE_NAME, + .description = "Run custom shell scripts", + .parseCommandOptions = (void*) ffParseCommandCommandOptions, + .parseJsonObject = (void*) ffParseCommandJsonObject, + .printModule = (void*) ffPrintCommand, + .generateJsonResult = (void*) ffGenerateCommandJsonResult, + .generateJsonConfig = (void*) ffGenerateCommandJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Command result", "result"}, + })) +}; void ffInitCommandOptions(FFCommandOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_COMMAND_MODULE_NAME, - "Running custom shell scripts", - ffParseCommandCommandOptions, - ffParseCommandJsonObject, - ffPrintCommand, - ffGenerateCommandJsonResult, - ffPrintCommandHelpFormat, - ffGenerateCommandJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); ffStrbufInitStatic(&options->shell, diff --git a/src/modules/cpu/cpu.c b/src/modules/cpu/cpu.c index 1a924ca5d..f059883a3 100644 --- a/src/modules/cpu/cpu.c +++ b/src/modules/cpu/cpu.c @@ -6,8 +6,6 @@ #include "modules/cpu/cpu.h" #include "util/stringUtils.h" -#define FF_CPU_NUM_FORMAT_ARGS 10 - static int sortCores(const FFCPUCore* a, const FFCPUCore* b) { return (int)b->freq - (int)a->freq; @@ -104,7 +102,7 @@ void ffPrintCPU(FFCPUOptions* options) FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate(); ffTempsAppendNum(cpu.temperature, &tempStr, options->tempConfig, &options->moduleArgs); - FF_PRINT_FORMAT_CHECKED(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPU_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(cpu.name, "name"), FF_FORMAT_ARG(cpu.vendor, "vendor"), FF_FORMAT_ARG(cpu.coresPhysical, "cores-physical"), @@ -241,35 +239,31 @@ void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_ ffStrbufDestroy(&cpu.vendor); } -void ffPrintCPUHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CPU_MODULE_NAME, "{1} ({5}) @ {7} GHz", FF_CPU_NUM_FORMAT_ARGS, ((const char* []) { - "Name - name", - "Vendor - vendor", - "Physical core count - cores-physical", - "Logical core count - cores-logical", - "Online core count - cores-online", - "Base frequency (formatted) - freq-base", - "Max frequency (formatted) - freq-max", - "Temperature (formatted) - temperature", - "Logical core count grouped by frequency - core-types", - "Processor package count - packages", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_CPU_MODULE_NAME, + .description = "Print CPU name, frequency, etc", + .parseCommandOptions = (void*) ffParseCPUCommandOptions, + .parseJsonObject = (void*) ffParseCPUJsonObject, + .printModule = (void*) ffPrintCPU, + .generateJsonResult = (void*) ffGenerateCPUJsonResult, + .generateJsonConfig = (void*) ffGenerateCPUJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Name", "name"}, + {"Vendor", "vendor"}, + {"Physical core count", "cores-physical"}, + {"Logical core count", "cores-logical"}, + {"Online core count", "cores-online"}, + {"Base frequency (formatted)", "freq-base"}, + {"Max frequency (formatted)", "freq-max"}, + {"Temperature (formatted)", "temperature"}, + {"Logical core count grouped by frequency", "core-types"}, + {"Processor package count", "packages"}, + })) +}; void ffInitCPUOptions(FFCPUOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_CPU_MODULE_NAME, - "Print CPU name, frequency, etc", - ffParseCPUCommandOptions, - ffParseCPUJsonObject, - ffPrintCPU, - ffGenerateCPUJsonResult, - ffPrintCPUHelpFormat, - ffGenerateCPUJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); options->temp = false; options->tempConfig = (FFColorRangeConfig) { 60, 80 }; diff --git a/src/modules/cpucache/cpucache.c b/src/modules/cpucache/cpucache.c index f52ec5cfb..dd6f4c00d 100644 --- a/src/modules/cpucache/cpucache.c +++ b/src/modules/cpucache/cpucache.c @@ -5,7 +5,6 @@ #include "util/stringUtils.h" #define FF_CPUCACHE_DISPLAY_NAME "CPU Cache" -#define FF_CPUCACHE_NUM_FORMAT_ARGS 2 static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOptions* options) { @@ -22,7 +21,7 @@ static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOption else { uint32_t index = i + 1; - FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){ + FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) { FF_FORMAT_ARG(index, "index"), FF_FORMAT_ARG(levelStr, "level"), FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), @@ -61,7 +60,7 @@ static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOption { FF_STRBUF_AUTO_DESTROY buffer2 = ffStrbufCreate(); ffParseSize(sum, &buffer2); - FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_CPUCACHE_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) { FF_FORMAT_ARG(buffer, "result"), FF_FORMAT_ARG(buffer2, "sum"), })); @@ -94,7 +93,7 @@ static void printCPUCacheCompact(const FFCPUCacheResult* result, FFCPUCacheOptio { FF_STRBUF_AUTO_DESTROY buffer2 = ffStrbufCreate(); ffParseSize(sum, &buffer2); - FF_PRINT_FORMAT_CHECKED(FF_CPUCACHE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPUCACHE_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_CPUCACHE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(buffer, "result"), FF_FORMAT_ARG(buffer2, "sum"), })); @@ -228,27 +227,23 @@ void ffGenerateCPUCacheJsonResult(FF_MAYBE_UNUSED FFCPUCacheOptions* options, yy ffListDestroy(&result.caches[3]); } -void ffPrintCPUCacheHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CPUCACHE_DISPLAY_NAME, "{1}", FF_CPUCACHE_NUM_FORMAT_ARGS, ((const char* []) { - "Separate result - result", - "Sum result - sum", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_CPUCACHE_MODULE_NAME, + .description = "Print CPU cache sizes", + .parseCommandOptions = (void*) ffParseCPUCacheCommandOptions, + .parseJsonObject = (void*) ffParseCPUCacheJsonObject, + .printModule = (void*) ffPrintCPUCache, + .generateJsonResult = (void*) ffGenerateCPUCacheJsonResult, + .generateJsonConfig = (void*) ffGenerateCPUCacheJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Separate result", "result"}, + {"Sum result", "sum"}, + })) +}; void ffInitCPUCacheOptions(FFCPUCacheOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_CPUCACHE_MODULE_NAME, - "Print CPU cache sizes", - ffParseCPUCacheCommandOptions, - ffParseCPUCacheJsonObject, - ffPrintCPUCache, - ffGenerateCPUCacheJsonResult, - ffPrintCPUCacheHelpFormat, - ffGenerateCPUCacheJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); options->compact = false; diff --git a/src/modules/cpuusage/cpuusage.c b/src/modules/cpuusage/cpuusage.c index a224517c6..7149c667a 100644 --- a/src/modules/cpuusage/cpuusage.c +++ b/src/modules/cpuusage/cpuusage.c @@ -6,7 +6,6 @@ #include "util/stringUtils.h" #define FF_CPUUSAGE_DISPLAY_NAME "CPU Usage" -#define FF_CPUUSAGE_NUM_FORMAT_ARGS 8 void ffPrintCPUUsage(FFCPUUsageOptions* options) { @@ -94,7 +93,7 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options) if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) ffPercentAppendBar(&maxBar, maxValue, options->percent, &options->moduleArgs); - FF_PRINT_FORMAT_CHECKED(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPUUSAGE_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(avgNum, "avg"), FF_FORMAT_ARG(maxNum, "max"), FF_FORMAT_ARG(maxIndex, "max-index"), @@ -194,33 +193,29 @@ void ffGenerateCPUUsageJsonResult(FFCPUUsageOptions* options, yyjson_mut_doc* do } } -void ffPrintCPUUsageHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CPUUSAGE_MODULE_NAME, "{1}", FF_CPUUSAGE_NUM_FORMAT_ARGS, ((const char* []) { - "CPU usage (percentage num, average) - avg", - "CPU usage (percentage num, maximum) - max", - "CPU core index of maximum usage - max-index", - "CPU usage (percentage num, minimum) - min", - "CPU core index of minimum usage - min-index", - "CPU usage (percentage bar, average) - avg-bar", - "CPU usage (percentage bar, maximum) - max-bar", - "CPU usage (percentage bar, minimum) - min-bar", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_CPUUSAGE_MODULE_NAME, + .description = "Print CPU usage. Costs some time to collect data", + .parseCommandOptions = (void*) ffParseCPUUsageCommandOptions, + .parseJsonObject = (void*) ffParseCPUUsageJsonObject, + .printModule = (void*) ffPrintCPUUsage, + .generateJsonResult = (void*) ffGenerateCPUUsageJsonResult, + .generateJsonConfig = (void*) ffGenerateCPUUsageJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"CPU usage (percentage num, average)", "avg"}, + {"CPU usage (percentage num, maximum)", "max"}, + {"CPU core index of maximum usage", "max-index"}, + {"CPU usage (percentage num, minimum)", "min"}, + {"CPU core index of minimum usage", "min-index"}, + {"CPU usage (percentage bar, average)", "avg-bar"}, + {"CPU usage (percentage bar, maximum)", "max-bar"}, + {"CPU usage (percentage bar, minimum)", "min-bar"}, + })) +}; void ffInitCPUUsageOptions(FFCPUUsageOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_CPUUSAGE_MODULE_NAME, - "Print CPU usage. Costs some time to collect data", - ffParseCPUUsageCommandOptions, - ffParseCPUUsageJsonObject, - ffPrintCPUUsage, - ffGenerateCPUUsageJsonResult, - ffPrintCPUUsageHelpFormat, - ffGenerateCPUUsageJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰓅"); options->separate = false; options->percent = (FFPercentageModuleConfig) { 50, 80, 0 }; diff --git a/src/modules/cursor/cursor.c b/src/modules/cursor/cursor.c index 7026bda47..93372cdc8 100644 --- a/src/modules/cursor/cursor.c +++ b/src/modules/cursor/cursor.c @@ -4,8 +4,6 @@ #include "modules/cursor/cursor.h" #include "util/stringUtils.h" -#define FF_CURSOR_NUM_FORMAT_ARGS 2 - void ffPrintCursor(FFCursorOptions* options) { FFCursorResult result; @@ -38,7 +36,7 @@ void ffPrintCursor(FFCursorOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CURSOR_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(result.theme, "theme"), FF_FORMAT_ARG(result.size, "size"), })); @@ -110,27 +108,23 @@ void ffGenerateCursorJsonResult(FF_MAYBE_UNUSED FFCursorOptions* options, yyjson ffStrbufDestroy(&result.size); } -void ffPrintCursorHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CURSOR_MODULE_NAME, "{1} ({2}px)", FF_CURSOR_NUM_FORMAT_ARGS, ((const char* []) { - "Cursor theme - theme", - "Cursor size - size" - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_CURSOR_MODULE_NAME, + .description = "Print cursor style name", + .parseCommandOptions = (void*) ffParseCursorCommandOptions, + .parseJsonObject = (void*) ffParseCursorJsonObject, + .printModule = (void*) ffPrintCursor, + .generateJsonResult = (void*) ffGenerateCursorJsonResult, + .generateJsonConfig = (void*) ffGenerateCursorJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Cursor theme", "theme"}, + {"Cursor size", "size"}, + })), +}; void ffInitCursorOptions(FFCursorOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_CURSOR_MODULE_NAME, - "Print cursor style name", - ffParseCursorCommandOptions, - ffParseCursorJsonObject, - ffPrintCursor, - ffGenerateCursorJsonResult, - ffPrintCursorHelpFormat, - ffGenerateCursorJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰆿"); } diff --git a/src/modules/custom/custom.c b/src/modules/custom/custom.c index 200556011..73f98dce6 100644 --- a/src/modules/custom/custom.c +++ b/src/modules/custom/custom.c @@ -44,19 +44,18 @@ void ffParseCustomJsonObject(FFCustomOptions* options, yyjson_val* module) } } +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_CUSTOM_MODULE_NAME, + .description = "Print a custom string, with or without key", + .parseCommandOptions = (void*) ffParseCustomCommandOptions, + .parseJsonObject = (void*) ffParseCustomJsonObject, + .printModule = (void*) ffPrintCustom, + .generateJsonConfig = (void*) ffGenerateCustomJsonConfig, +}; + void ffInitCustomOptions(FFCustomOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_CUSTOM_MODULE_NAME, - "Print a custom string, with or without key", - ffParseCustomCommandOptions, - ffParseCustomJsonObject, - ffPrintCustom, - NULL, - NULL, - ffGenerateCustomJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); ffStrbufSetStatic(&options->moduleArgs.key, " "); } diff --git a/src/modules/datetime/datetime.c b/src/modules/datetime/datetime.c index 897e2c056..09c62e7a4 100644 --- a/src/modules/datetime/datetime.c +++ b/src/modules/datetime/datetime.c @@ -9,7 +9,6 @@ #pragma GCC diagnostic ignored "-Wformat" // warning: unknown conversion type character 'F' in format #define FF_DATETIME_DISPLAY_NAME "Date & Time" -#define FF_DATETIME_NUM_FORMAT_ARGS 23 typedef struct FFDateTimeResult { @@ -67,7 +66,7 @@ void ffPrintDateTimeFormat(struct tm* tm, const FFModuleArgs* moduleArgs) strftime(result.offsetFromUtc, sizeof(result.offsetFromUtc), "%z", tm); strftime(result.timezoneName, sizeof(result.timezoneName), "%Z", tm); - FF_PRINT_FORMAT_CHECKED(FF_DATETIME_DISPLAY_NAME, 0, moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_DATETIME_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_DATETIME_DISPLAY_NAME, 0, moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(result.year, "year"), // 1 FF_FORMAT_ARG(result.yearShort, "year-short"), // 2 FF_FORMAT_ARG(result.month, "month"), // 3 @@ -158,48 +157,44 @@ void ffGenerateDateTimeJsonResult(FF_MAYBE_UNUSED FFDateTimeOptions* options, yy yyjson_mut_obj_add_strcpy(doc, module, "result", ffTimeToFullStr(ffTimeGetNow())); } -void ffPrintDateTimeHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DATETIME_MODULE_NAME, "{1}-{4}-{23} {14}:{18}:{20}", FF_DATETIME_NUM_FORMAT_ARGS, ((const char* []) { - "year - year", - "last two digits of year - year-short", - "month - month", - "month with leading zero - month-pretty", - "month name - month-name", - "month name short - month-name-short", - "week number on year - week", - "weekday - weekday", - "weekday short - weekday-short", - "day in year - day-in-year", - "day in month - day-in-month", - "day in week - day-in-week", - "hour - hour", - "hour with leading zero - hour-pretty", - "hour 12h format - hour-12", - "hour 12h format with leading zero - hour-12-pretty", - "minute - minute", - "minute with leading zero - minute-pretty", - "second - second", - "second with leading zero - second-pretty", - "offset from UTC in the ISO 8601 format - offset-from-utc", - "locale-dependent timezone name or abbreviation - timezone-name", - "day in month with leading zero - day-pretty", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_DATETIME_MODULE_NAME, + .description = "Print current date and time", + .parseCommandOptions = (void*) ffParseDateTimeCommandOptions, + .parseJsonObject = (void*) ffParseDateTimeJsonObject, + .printModule = (void*) ffPrintDateTime, + .generateJsonResult = (void*) ffGenerateDateTimeJsonResult, + .generateJsonConfig = (void*) ffGenerateDateTimeJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Year", "year"}, + {"Last two digits of year", "year-short"}, + {"Month", "month"}, + {"Month with leading zero", "month-pretty"}, + {"Month name", "month-name"}, + {"Month name short", "month-name-short"}, + {"Week number on year", "week"}, + {"Weekday", "weekday"}, + {"Weekday short", "weekday-short"}, + {"Day in year", "day-in-year"}, + {"Day in month", "day-in-month"}, + {"Day in week", "day-in-week"}, + {"Hour", "hour"}, + {"Hour with leading zero", "hour-pretty"}, + {"Hour 12h format", "hour-12"}, + {"Hour 12h format with leading zero", "hour-12-pretty"}, + {"Minute", "minute"}, + {"Minute with leading zero", "minute-pretty"}, + {"Second", "second"}, + {"Second with leading zero", "second-pretty"}, + {"Offset from UTC in the ISO 8601 format", "offset-from-utc"}, + {"Locale-dependent timezone name or abbreviation", "timezone-name"}, + {"Day in month with leading zero", "day-pretty"}, + })) +}; void ffInitDateTimeOptions(FFDateTimeOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_DATETIME_MODULE_NAME, - "Print current date and time", - ffParseDateTimeCommandOptions, - ffParseDateTimeJsonObject, - ffPrintDateTime, - ffGenerateDateTimeJsonResult, - ffPrintDateTimeHelpFormat, - ffGenerateDateTimeJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/de/de.c b/src/modules/de/de.c index 3decd8318..36746fa9a 100644 --- a/src/modules/de/de.c +++ b/src/modules/de/de.c @@ -5,8 +5,6 @@ #include "modules/de/de.h" #include "util/stringUtils.h" -#define FF_DE_NUM_FORMAT_ARGS 3 - void ffPrintDE(FFDEOptions* options) { const FFDisplayServerResult* result = ffConnectDisplayServer(); @@ -36,7 +34,7 @@ void ffPrintDE(FFDEOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_DE_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(result->deProcessName, "process-name"), FF_FORMAT_ARG(result->dePrettyName, "pretty-name"), FF_FORMAT_ARG(version, "version") @@ -113,28 +111,24 @@ void ffGenerateDEJsonResult(FF_MAYBE_UNUSED FFDEOptions* options, yyjson_mut_doc yyjson_mut_obj_add_strbuf(doc, obj, "version", &version); } -void ffPrintDEHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DE_MODULE_NAME, "{2} {3}", FF_DE_NUM_FORMAT_ARGS, ((const char* []) { - "DE process name - process-name", - "DE pretty name - pretty-name", - "DE version - version" - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_DE_MODULE_NAME, + .description = "Print desktop environment name", + .parseCommandOptions = (void*) ffParseDECommandOptions, + .parseJsonObject = (void*) ffParseDEJsonObject, + .printModule = (void*) ffPrintDE, + .generateJsonResult = (void*) ffGenerateDEJsonResult, + .generateJsonConfig = (void*) ffGenerateDEJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"DE process name", "process-name"}, + {"DE pretty name", "pretty-name"}, + {"DE version", "version"}, + })) +}; void ffInitDEOptions(FFDEOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_DE_MODULE_NAME, - "Print desktop environment name", - ffParseDECommandOptions, - ffParseDEJsonObject, - ffPrintDE, - ffGenerateDEJsonResult, - ffPrintDEHelpFormat, - ffGenerateDEJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); options->slowVersionDetection = false; diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index a095d8c59..9e2ef2611 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -7,7 +7,6 @@ #include "modules/disk/disk.h" #include "util/stringUtils.h" -#define FF_DISK_NUM_FORMAT_ARGS 14 #pragma GCC diagnostic ignored "-Wsign-conversion" static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index) @@ -35,7 +34,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index } else { - FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 5, ((FFformatarg[]){ + FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) { FF_FORMAT_ARG(disk->mountpoint, "mountpoint"), FF_FORMAT_ARG(disk->name, "name"), FF_FORMAT_ARG(disk->mountFrom, "mount-from"), @@ -126,7 +125,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index bool isHidden = !!(disk->type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT); bool isReadOnly = !!(disk->type & FF_DISK_VOLUME_TYPE_READONLY_BIT); - FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISK_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) { FF_FORMAT_ARG(usedPretty, "size-used"), FF_FORMAT_ARG(totalPretty, "size-total"), FF_FORMAT_ARG(bytesPercentageNum, "size-percentage"), @@ -440,39 +439,36 @@ void ffGenerateDiskJsonResult(FFDiskOptions* options, yyjson_mut_doc* doc, yyjso } } -void ffPrintDiskHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISK_MODULE_NAME, "{1} / {2} ({3}) - {9}", FF_DISK_NUM_FORMAT_ARGS, ((const char* []) { - "Size used - size-used", - "Size total - size-total", - "Size percentage num - size-percentage", - "Files used - files-used", - "Files total - files-total", - "Files percentage num - files-percentage", - "True if external volume - is-external", - "True if hidden volume - is-hidden", - "Filesystem - filesystem", - "Label / name - name", - "True if read-only - is-readonly", - "Create time in local timezone - create-time", - "Size percentage bar - size-percentage-bar", - "Files percentage bar - files-percentage-bar", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_DISK_MODULE_NAME, + .description = "Print partitions, space usage, file system, etc", + .parseCommandOptions = (void*) ffParseDiskCommandOptions, + .parseJsonObject = (void*) ffParseDiskJsonObject, + .printModule = (void*) ffPrintDisk, + .generateJsonResult = (void*) ffGenerateDiskJsonResult, + .generateJsonConfig = (void*) ffGenerateDiskJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Size used", "size-used"}, + {"Size total", "size-total"}, + {"Size percentage num", "size-percentage"}, + {"Files used", "files-used"}, + {"Files total", "files-total"}, + {"Files percentage num", "files-percentage"}, + {"True if external volume", "is-external"}, + {"True if hidden volume", "is-hidden"}, + {"Filesystem", "filesystem"}, + {"Label / name", "name"}, + {"True if read-only", "is-readonly"}, + {"Create time in local timezone", "create-time"}, + {"Size percentage bar", "size-percentage-bar"}, + {"Files percentage bar", "files-percentage-bar"}, + {}, + })) +}; void ffInitDiskOptions(FFDiskOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_DISK_MODULE_NAME, - "Print partitions, space usage, file system, etc", - ffParseDiskCommandOptions, - ffParseDiskJsonObject, - ffPrintDisk, - ffGenerateDiskJsonResult, - ffPrintDiskHelpFormat, - ffGenerateDiskJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); ffStrbufInit(&options->folders); diff --git a/src/modules/diskio/diskio.c b/src/modules/diskio/diskio.c index da4e8e607..c9bafe68d 100644 --- a/src/modules/diskio/diskio.c +++ b/src/modules/diskio/diskio.c @@ -6,7 +6,6 @@ #include "util/stringUtils.h" #define FF_DISKIO_DISPLAY_NAME "Disk IO" -#define FF_DISKIO_NUM_FORMAT_ARGS 8 static int sortDevices(const FFDiskIOResult* left, const FFDiskIOResult* right) { @@ -22,7 +21,7 @@ static void formatKey(const FFDiskIOOptions* options, FFDiskIOResult* dev, uint3 else { ffStrbufClear(key); - FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 4, ((FFformatarg[]){ + FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, ((FFformatarg[]){ FF_FORMAT_ARG(index, "index"), FF_FORMAT_ARG(dev->name, "name"), FF_FORMAT_ARG(dev->devPath, "dev-path"), @@ -75,7 +74,7 @@ void ffPrintDiskIO(FFDiskIOOptions* options) ffParseSize(dev->bytesWritten, &buffer2); if (!options->detectTotal) ffStrbufAppendS(&buffer, "/s"); - FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISKIO_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]){ FF_FORMAT_ARG(buffer, "size-read"), FF_FORMAT_ARG(buffer2, "size-written"), FF_FORMAT_ARG(dev->name, "name"), @@ -203,33 +202,29 @@ void ffGenerateDiskIOJsonResult(FFDiskIOOptions* options, yyjson_mut_doc* doc, y } } -void ffPrintDiskIOHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISKIO_MODULE_NAME, "{1} (R) - {2} (W)", FF_DISKIO_NUM_FORMAT_ARGS, ((const char* []) { - "Size of data read [per second] (formatted) - size-read", - "Size of data written [per second] (formatted) - size-written", - "Device name - name", - "Device raw file path - dev-path", - "Size of data read [per second] (in bytes) - bytes-read", - "Size of data written [per second] (in bytes) - bytes-written", - "Number of reads - read-count", - "Number of writes - write-count", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_DISKIO_MODULE_NAME, + .description = "Print physical disk I/O throughput", + .parseCommandOptions = (void*) ffParseDiskIOCommandOptions, + .parseJsonObject = (void*) ffParseDiskIOJsonObject, + .printModule = (void*) ffPrintDiskIO, + .generateJsonResult = (void*) ffGenerateDiskIOJsonResult, + .generateJsonConfig = (void*) ffGenerateDiskIOJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Size of data read [per second] (formatted)", "size-read"}, + {"Size of data written [per second] (formatted)", "size-written"}, + {"Device name", "name"}, + {"Device raw file path", "dev-path"}, + {"Size of data read [per second] (in bytes)", "bytes-read"}, + {"Size of data written [per second] (in bytes)", "bytes-written"}, + {"Number of reads", "read-count"}, + {"Number of writes", "write-count"}, + })) +}; void ffInitDiskIOOptions(FFDiskIOOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_DISKIO_MODULE_NAME, - "Print physical disk I/O throughput", - ffParseDiskIOCommandOptions, - ffParseDiskIOJsonObject, - ffPrintDiskIO, - ffGenerateDiskIOJsonResult, - ffPrintDiskIOHelpFormat, - ffGenerateDiskIOJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰓅"); ffStrbufInit(&options->namePrefix); diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 07884d501..fdf427682 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -6,8 +6,6 @@ #include -#define FF_DISPLAY_NUM_FORMAT_ARGS 24 - static int sortByNameAsc(FFDisplayResult* a, FFDisplayResult* b) { return ffStrbufComp(&a->name, &b->name); @@ -91,7 +89,7 @@ void ffPrintDisplay(FFDisplayOptions* options) } else { - FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 4, ((FFformatarg[]){ + FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) { FF_FORMAT_ARG(moduleIndex, "index"), FF_FORMAT_ARG(result->name, "name"), FF_FORMAT_ARG(displayType, "type"), @@ -186,7 +184,7 @@ void ffPrintDisplay(FFDisplayOptions* options) double scaleFactor = (double) result->width / (double) result->scaledWidth; - FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISPLAY_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) { FF_FORMAT_ARG(result->width, "width"), FF_FORMAT_ARG(result->height, "height"), FF_FORMAT_ARG(refreshRate, "refresh-rate"), @@ -435,49 +433,45 @@ void ffGenerateDisplayJsonResult(FF_MAYBE_UNUSED FFDisplayOptions* options, yyjs } } -void ffPrintDisplayHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISPLAY_MODULE_NAME, "{1}x{2} @ {3}Hz (as {4}x{5}) [{7}]", FF_DISPLAY_NUM_FORMAT_ARGS, ((const char* []) { - "Screen configured width (in pixels) - width", - "Screen configured height (in pixels) - height", - "Screen configured refresh rate (in Hz) - refresh-rate", - "Screen scaled width (in pixels) - scaled-width", - "Screen scaled height (in pixels) - scaled-height", - "Screen name - name", - "Screen type (builtin, external or unknown) - type", - "Screen rotation (in degrees) - rotation", - "True if being the primary screen - is-primary", - "Screen physical width (in millimeters) - physical-width", - "Screen physical height (in millimeters) - physical-height", - "Physical diagonal length in inches - inch", - "Pixels per inch (PPI) - ppi", - "Bits per color channel - bit-depth", - "True if high dynamic range (HDR) mode is enabled - hdr-enabled", - "Year of manufacturing - manufacture-year", - "Nth week of manufacturing in the year - manufacture-week", - "Serial number - serial", - "The platform API used when detecting the display - platform-api", - "True if the display is HDR compatible - hdr-compatible", - "HiDPI scale factor - scale-factor", - "Screen preferred width (in pixels) - preferred-width", - "Screen preferred height (in pixels) - preferred-height", - "Screen preferred refresh rate (in Hz) - preferred-refresh-rate", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_DISPLAY_MODULE_NAME, + .description = "Print resolutions, refresh rates, etc", + .parseCommandOptions = (void*) ffParseDisplayCommandOptions, + .parseJsonObject = (void*) ffParseDisplayJsonObject, + .printModule = (void*) ffPrintDisplay, + .generateJsonResult = (void*) ffGenerateDisplayJsonResult, + .generateJsonConfig = (void*) ffGenerateDisplayJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Screen configured width (in pixels)", "width"}, + {"Screen configured height (in pixels)", "height"}, + {"Screen configured refresh rate (in Hz)", "refresh-rate"}, + {"Screen scaled width (in pixels)", "scaled-width"}, + {"Screen scaled height (in pixels)", "scaled-height"}, + {"Screen name", "name"}, + {"Screen type (builtin, external or unknown)", "type"}, + {"Screen rotation (in degrees)", "rotation"}, + {"True if being the primary screen", "is-primary"}, + {"Screen physical width (in millimeters)", "physical-width"}, + {"Screen physical height (in millimeters)", "physical-height"}, + {"Physical diagonal length in inches", "inch"}, + {"Pixels per inch (PPI)", "ppi"}, + {"Bits per color channel", "bit-depth"}, + {"True if high dynamic range (HDR) mode is enabled", "hdr-enabled"}, + {"Year of manufacturing", "manufacture-year"}, + {"Nth week of manufacturing in the year", "manufacture-week"}, + {"Serial number", "serial"}, + {"The platform API used when detecting the display", "platform-api"}, + {"True if the display is HDR compatible", "hdr-compatible"}, + {"HiDPI scale factor", "scale-factor"}, + {"Screen preferred width (in pixels)", "preferred-width"}, + {"Screen preferred height (in pixels)", "preferred-height"}, + {"Screen preferred refresh rate (in Hz)", "preferred-refresh-rate"}, + })) +}; void ffInitDisplayOptions(FFDisplayOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_DISPLAY_MODULE_NAME, - "Print resolutions, refresh rates, etc", - ffParseDisplayCommandOptions, - ffParseDisplayJsonObject, - ffPrintDisplay, - ffGenerateDisplayJsonResult, - ffPrintDisplayHelpFormat, - ffGenerateDisplayJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰍹"); options->compactType = FF_DISPLAY_COMPACT_TYPE_NONE; options->preciseRefreshRate = false; diff --git a/src/modules/dns/dns.c b/src/modules/dns/dns.c index fe4654f23..29c04af07 100644 --- a/src/modules/dns/dns.c +++ b/src/modules/dns/dns.c @@ -4,8 +4,6 @@ #include "modules/dns/dns.h" #include "util/stringUtils.h" -#define FF_DNS_NUM_FORMAT_ARGS 1 - void ffPrintDNS(FFDNSOptions* options) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFstrbuf)); @@ -48,7 +46,7 @@ void ffPrintDNS(FFDNSOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_DNS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_DNS_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_DNS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(buf, "result"), })); } @@ -166,26 +164,22 @@ void ffGenerateDNSJsonResult(FF_MAYBE_UNUSED FFDNSOptions* options, yyjson_mut_d } } -void ffPrintDNSHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DNS_MODULE_NAME, "{1}", FF_DNS_NUM_FORMAT_ARGS, ((const char* []) { - "DNS result - result", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_DNS_MODULE_NAME, + .description = "Print configured DNS servers", + .parseCommandOptions = (void*) ffParseDNSCommandOptions, + .parseJsonObject = (void*) ffParseDNSJsonObject, + .printModule = (void*) ffPrintDNS, + .generateJsonResult = (void*) ffGenerateDNSJsonResult, + .generateJsonConfig = (void*) ffGenerateDNSJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"DNS result", "result"}, + })) +}; void ffInitDNSOptions(FFDNSOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_DNS_MODULE_NAME, - "Print configured DNS servers", - ffParseDNSCommandOptions, - ffParseDNSJsonObject, - ffPrintDNS, - ffGenerateDNSJsonResult, - ffPrintDNSHelpFormat, - ffGenerateDNSJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰇖"); options->showType = FF_DNS_TYPE_BOTH; diff --git a/src/modules/editor/editor.c b/src/modules/editor/editor.c index b814a55e9..61ea18d7f 100644 --- a/src/modules/editor/editor.c +++ b/src/modules/editor/editor.c @@ -5,8 +5,6 @@ #include "modules/editor/editor.h" #include "util/stringUtils.h" -#define FF_EDITOR_NUM_FORMAT_ARGS 5 - void ffPrintEditor(FFEditorOptions* options) { FFEditorResult result = { @@ -41,7 +39,7 @@ void ffPrintEditor(FFEditorOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_EDITOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_EDITOR_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_EDITOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(result.type, "type"), FF_FORMAT_ARG(result.name, "name"), FF_FORMAT_ARG(result.exe, "exe-name"), @@ -120,30 +118,26 @@ void ffGenerateEditorJsonResult(FF_MAYBE_UNUSED FFEditorOptions* options, yyjson ffStrbufDestroy(&result.version); } -void ffPrintEditorHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_EDITOR_MODULE_NAME, "{2} ({4})", FF_EDITOR_NUM_FORMAT_ARGS, ((const char* []) { - "Type (Visual / Editor) - type", - "Name - name", - "Exe name of real path - exe-name", - "Full path of real path - full-path", - "Version - version", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_EDITOR_MODULE_NAME, + .description = "Print information of the default editor ($VISUAL or $EDITOR)", + .parseCommandOptions = (void*) ffParseEditorCommandOptions, + .parseJsonObject = (void*) ffParseEditorJsonObject, + .printModule = (void*) ffPrintEditor, + .generateJsonResult = (void*) ffGenerateEditorJsonResult, + .generateJsonConfig = (void*) ffGenerateEditorJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Type (Visual / Editor)", "type"}, + {"Name", "name"}, + {"Exe name of real path", "exe-name"}, + {"Full path of real path", "full-path"}, + {"Version", "version"}, + })) +}; void ffInitEditorOptions(FFEditorOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_EDITOR_MODULE_NAME, - "Print information of the default editor ($VISUAL or $EDITOR)", - ffParseEditorCommandOptions, - ffParseEditorJsonObject, - ffPrintEditor, - ffGenerateEditorJsonResult, - ffPrintEditorHelpFormat, - ffGenerateEditorJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󱞎"); } diff --git a/src/modules/font/font.c b/src/modules/font/font.c index 3fbc9ac94..242b685ee 100644 --- a/src/modules/font/font.c +++ b/src/modules/font/font.c @@ -4,8 +4,6 @@ #include "modules/font/font.h" #include "util/stringUtils.h" -#define FF_FONT_NUM_FORMAT_ARGS (FF_DETECT_FONT_NUM_FONTS + 1) - void ffPrintFont(FFFontOptions* options) { FFFontResult font; @@ -28,7 +26,7 @@ void ffPrintFont(FFFontOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_FONT_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(font.fonts[0], "font1"), FF_FORMAT_ARG(font.fonts[1], "font2"), FF_FORMAT_ARG(font.fonts[2], "font3"), @@ -104,30 +102,26 @@ void ffGenerateFontJsonResult(FF_MAYBE_UNUSED FFFontOptions* options, yyjson_mut ffStrbufDestroy(&font.fonts[i]); } -void ffPrintFontHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_FONT_MODULE_NAME, "{5}", FF_FONT_NUM_FORMAT_ARGS, ((const char* []) { - "Font 1 - font1", - "Font 2 - font2", - "Font 3 - font3", - "Font 4 - font4", - "Combined fonts for display - combined" - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_FONT_MODULE_NAME, + .description = "Print system font names", + .parseCommandOptions = (void*) ffParseFontCommandOptions, + .parseJsonObject = (void*) ffParseFontJsonObject, + .printModule = (void*) ffPrintFont, + .generateJsonResult = (void*) ffGenerateFontJsonResult, + .generateJsonConfig = (void*) ffGenerateFontJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Font 1", "font1"}, + {"Font 2", "font2"}, + {"Font 3", "font3"}, + {"Font 4", "font4"}, + {"Combined fonts for display", "combined"}, + })) +}; void ffInitFontOptions(FFFontOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_FONT_MODULE_NAME, - "Print system font name", - ffParseFontCommandOptions, - ffParseFontJsonObject, - ffPrintFont, - ffGenerateFontJsonResult, - ffPrintFontHelpFormat, - ffGenerateFontJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/gamepad/gamepad.c b/src/modules/gamepad/gamepad.c index 82e1b29af..50be37796 100644 --- a/src/modules/gamepad/gamepad.c +++ b/src/modules/gamepad/gamepad.c @@ -5,8 +5,6 @@ #include "modules/gamepad/gamepad.h" #include "util/stringUtils.h" -#define FF_GAMEPAD_NUM_FORMAT_ARGS 4 - static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device, uint8_t index) { FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type; @@ -43,7 +41,7 @@ static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) ffPercentAppendBar(&percentageBar, device->battery, options->percent, &options->moduleArgs); - FF_PRINT_FORMAT_CHECKED(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_GAMEPAD_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(device->name, "name"), FF_FORMAT_ARG(device->serial, "serial"), FF_FORMAT_ARG(percentageNum, "battery-percentage"), @@ -149,29 +147,25 @@ void ffGenerateGamepadJsonResult(FF_MAYBE_UNUSED FFGamepadOptions* options, yyjs } } -void ffPrintGamepadHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_GAMEPAD_MODULE_NAME, "{1} ({3})", FF_GAMEPAD_NUM_FORMAT_ARGS, ((const char* []) { - "Name - name", - "Serial number - serial", - "Battery percentage num - battery-percentage", - "Battery percentage bar - battery-percentage-bar", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_GAMEPAD_MODULE_NAME, + .description = "List (connected) gamepads", + .parseCommandOptions = (void*) ffParseGamepadCommandOptions, + .parseJsonObject = (void*) ffParseGamepadJsonObject, + .printModule = (void*) ffPrintGamepad, + .generateJsonResult = (void*) ffGenerateGamepadJsonResult, + .generateJsonConfig = (void*) ffGenerateGamepadJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Name", "name"}, + {"Serial number", "serial"}, + {"Battery percentage num", "battery-percentage"}, + {"Battery percentage bar", "battery-percentage-bar"}, + })) +}; void ffInitGamepadOptions(FFGamepadOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_GAMEPAD_MODULE_NAME, - "List connected gamepads", - ffParseGamepadCommandOptions, - ffParseGamepadJsonObject, - ffPrintGamepad, - ffGenerateGamepadJsonResult, - ffPrintGamepadHelpFormat, - ffGenerateGamepadJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰺵"); options->percent = (FFPercentageModuleConfig) { 50, 20, 0 }; } diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index 3489fc57e..887a8a899 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -10,8 +10,6 @@ #include -#define FF_GPU_NUM_FORMAT_ARGS 13 - static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResult* gpu) { const char* type; @@ -90,7 +88,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu FF_STRBUF_AUTO_DESTROY frequency = ffStrbufCreate(); ffParseFrequency(gpu->frequency, &frequency); - FF_PRINT_FORMAT_CHECKED(FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_GPU_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(gpu->vendor, "vendor"), FF_FORMAT_ARG(gpu->name, "name"), FF_FORMAT_ARG(gpu->driver, "driver"), @@ -394,38 +392,34 @@ void ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_ } } -void ffPrintGPUHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_GPU_MODULE_NAME, "{1} {2}", FF_GPU_NUM_FORMAT_ARGS, ((const char* []) { - "GPU vendor - vendor", - "GPU name - name", - "GPU driver - driver", - "GPU temperature - temperature", - "GPU core count - core-count", - "GPU type - type", - "GPU total dedicated memory - dedicated-total", - "GPU used dedicated memory - dedicated-used", - "GPU total shared memory - shared-total", - "GPU used shared memory - shared-used", - "The platform API used when detecting the GPU - platform-api", - "Current frequency in GHz - frequency", - "GPU vendor specific index - index", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_GPU_MODULE_NAME, + .description = "Print GPU names, graphic memory size, type, etc", + .parseCommandOptions = (void*) ffParseGPUCommandOptions, + .parseJsonObject = (void*) ffParseGPUJsonObject, + .printModule = (void*) ffPrintGPU, + .generateJsonResult = (void*) ffGenerateGPUJsonResult, + .generateJsonConfig = (void*) ffGenerateGPUJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"GPU vendor", "vendor"}, + {"GPU name", "name"}, + {"GPU driver", "driver"}, + {"GPU temperature", "temperature"}, + {"GPU core count", "core-count"}, + {"GPU type", "type"}, + {"GPU total dedicated memory", "dedicated-total"}, + {"GPU used dedicated memory", "dedicated-used"}, + {"GPU total shared memory", "shared-total"}, + {"GPU used shared memory", "shared-used"}, + {"The platform API used when detecting the GPU", "platform-api"}, + {"Current frequency in GHz", "frequency"}, + {"GPU vendor specific index", "index"}, + })), +}; void ffInitGPUOptions(FFGPUOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_GPU_MODULE_NAME, - "Print GPU names, graphic memory size, type, etc", - ffParseGPUCommandOptions, - ffParseGPUJsonObject, - ffPrintGPU, - ffGenerateGPUJsonResult, - ffPrintGPUHelpFormat, - ffGenerateGPUJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰾲"); options->driverSpecific = false; diff --git a/src/modules/host/host.c b/src/modules/host/host.c index c63a9896e..170a1b440 100644 --- a/src/modules/host/host.c +++ b/src/modules/host/host.c @@ -4,8 +4,6 @@ #include "modules/host/host.h" #include "util/stringUtils.h" -#define FF_HOST_NUM_FORMAT_ARGS 7 - void ffPrintHost(FFHostOptions* options) { FFHostResult host; @@ -48,7 +46,7 @@ void ffPrintHost(FFHostOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_HOST_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(host.family, "family"), FF_FORMAT_ARG(host.name, "name"), FF_FORMAT_ARG(host.version, "version"), @@ -147,32 +145,28 @@ void ffGenerateHostJsonResult(FF_MAYBE_UNUSED FFHostOptions* options, yyjson_mut ffStrbufDestroy(&host.vendor); } -void ffPrintHostHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_HOST_MODULE_NAME, "{2} {3}", FF_HOST_NUM_FORMAT_ARGS, ((const char* []) { - "product family - family", - "product name - name", - "product version - version", - "product sku - sku", - "product vendor - vendor", - "product serial number - serial", - "product uuid - uuid", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_HOST_MODULE_NAME, + .description = "Print product name of your computer", + .parseCommandOptions = (void*) ffParseHostCommandOptions, + .parseJsonObject = (void*) ffParseHostJsonObject, + .printModule = (void*) ffPrintHost, + .generateJsonResult = (void*) ffGenerateHostJsonResult, + .generateJsonConfig = (void*) ffGenerateHostJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Product family", "family"}, + {"Product name", "name"}, + {"Product version", "version"}, + {"Product sku", "sku"}, + {"Product vendor", "vendor"}, + {"Product serial number", "serial"}, + {"Product uuid", "uuid"}, + })) +}; void ffInitHostOptions(FFHostOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_HOST_MODULE_NAME, - "Print product name of your computer", - ffParseHostCommandOptions, - ffParseHostJsonObject, - ffPrintHost, - ffGenerateHostJsonResult, - ffPrintHostHelpFormat, - ffGenerateHostJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰌢"); } diff --git a/src/modules/icons/icons.c b/src/modules/icons/icons.c index 891aeb572..bfc846a99 100644 --- a/src/modules/icons/icons.c +++ b/src/modules/icons/icons.c @@ -4,8 +4,6 @@ #include "modules/icons/icons.h" #include "util/stringUtils.h" -#define FF_ICONS_NUM_FORMAT_ARGS 2 - void ffPrintIcons(FFIconsOptions* options) { FFIconsResult result = { @@ -35,7 +33,7 @@ void ffPrintIcons(FFIconsOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_ICONS_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(result.icons1, "icons1"), FF_FORMAT_ARG(result.icons2, "icons2"), })); @@ -102,27 +100,23 @@ void ffGenerateIconsJsonResult(FF_MAYBE_UNUSED FFIconsOptions* options, yyjson_m ffStrbufDestroy(&result.icons2); } -void ffPrintIconsHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_ICONS_MODULE_NAME, "{1}, {2}", FF_ICONS_NUM_FORMAT_ARGS, ((const char* []) { - "Icons part 1 - icons1", - "Icons part 2 - icons2", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_ICONS_MODULE_NAME, + .description = "Print icon style name", + .parseCommandOptions = (void*) ffParseIconsCommandOptions, + .parseJsonObject = (void*) ffParseIconsJsonObject, + .printModule = (void*) ffPrintIcons, + .generateJsonResult = (void*) ffGenerateIconsJsonResult, + .generateJsonConfig = (void*) ffGenerateIconsJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Icons part 1", "icons1"}, + {"Icons part 2", "icons2"}, + })) +}; void ffInitIconsOptions(FFIconsOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_ICONS_MODULE_NAME, - "Print icon style name", - ffParseIconsCommandOptions, - ffParseIconsJsonObject, - ffPrintIcons, - ffGenerateIconsJsonResult, - ffPrintIconsHelpFormat, - ffGenerateIconsJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/initsystem/initsystem.c b/src/modules/initsystem/initsystem.c index 7a2824a60..5821c7d54 100644 --- a/src/modules/initsystem/initsystem.c +++ b/src/modules/initsystem/initsystem.c @@ -4,7 +4,6 @@ #include "modules/initsystem/initsystem.h" #include "util/stringUtils.h" -#define FF_INITSYSTEM_NUM_FORMAT_ARGS 4 #define FF_INITSYSTEM_DISPLAY_NAME "Init System" void ffPrintInitSystem(FFInitSystemOptions* options) @@ -35,7 +34,7 @@ void ffPrintInitSystem(FFInitSystemOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_INITSYSTEM_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_INITSYSTEM_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_INITSYSTEM_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(result.name, "name"), FF_FORMAT_ARG(result.exe, "exe"), FF_FORMAT_ARG(result.version, "version"), @@ -113,29 +112,25 @@ void ffGenerateInitSystemJsonResult(FF_MAYBE_UNUSED FFInitSystemOptions* options ffStrbufDestroy(&result.version); } -void ffPrintInitSystemHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_INITSYSTEM_DISPLAY_NAME, "{1}", FF_INITSYSTEM_NUM_FORMAT_ARGS, ((const char* []) { - "init system name - name", - "init system exe path - exe", - "init system version path - version", - "init system pid - pid", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_INITSYSTEM_MODULE_NAME, + .description = "Print init system (pid 1) name and version", + .parseCommandOptions = (void*) ffParseInitSystemCommandOptions, + .parseJsonObject = (void*) ffParseInitSystemJsonObject, + .printModule = (void*) ffPrintInitSystem, + .generateJsonResult = (void*) ffGenerateInitSystemJsonResult, + .generateJsonConfig = (void*) ffGenerateInitSystemJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Init system name", "name"}, + {"Init system exe path", "exe"}, + {"Init system version path", "version"}, + {"Init system pid", "pid"}, + })) +}; void ffInitInitSystemOptions(FFInitSystemOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_INITSYSTEM_MODULE_NAME, - "Print init system (pid 1) name and version", - ffParseInitSystemCommandOptions, - ffParseInitSystemJsonObject, - ffPrintInitSystem, - ffGenerateInitSystemJsonResult, - ffPrintInitSystemHelpFormat, - ffGenerateInitSystemJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰿄"); } diff --git a/src/modules/kernel/kernel.c b/src/modules/kernel/kernel.c index 13b96c49c..75ca36758 100644 --- a/src/modules/kernel/kernel.c +++ b/src/modules/kernel/kernel.c @@ -3,8 +3,6 @@ #include "modules/kernel/kernel.h" #include "util/stringUtils.h" -#define FF_KERNEL_NUM_FORMAT_ARGS 6 - void ffPrintKernel(FFKernelOptions* options) { const FFPlatformSysinfo* info = &instance.state.platform.sysinfo; @@ -22,7 +20,7 @@ void ffPrintKernel(FFKernelOptions* options) { FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); ffParseSize(info->pageSize, &str); - FF_PRINT_FORMAT_CHECKED(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_KERNEL_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(info->name, "sysname"), FF_FORMAT_ARG(info->release, "release"), FF_FORMAT_ARG(info->version, "version"), @@ -81,31 +79,27 @@ void ffGenerateKernelJsonResult(FF_MAYBE_UNUSED FFKernelOptions* options, yyjson yyjson_mut_obj_add_uint(doc, obj, "pageSize", info->pageSize); } -void ffPrintKernelHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_KERNEL_MODULE_NAME, "{1} {2}", FF_KERNEL_NUM_FORMAT_ARGS, ((const char* []) { - "Sysname - sysname", - "Release - release", - "Version - version", - "Architecture - arch", - "Display version - display-version", - "Page size - page-size", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_KERNEL_MODULE_NAME, + .description = "Print system kernel version", + .parseCommandOptions = (void*) ffParseKernelCommandOptions, + .parseJsonObject = (void*) ffParseKernelJsonObject, + .printModule = (void*) ffPrintKernel, + .generateJsonResult = (void*) ffGenerateKernelJsonResult, + .generateJsonConfig = (void*) ffGenerateKernelJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Sysname", "sysname"}, + {"Release", "release"}, + {"Version", "version"}, + {"Architecture", "arch"}, + {"Display version", "display-version"}, + {"Page size", "page-size"}, + })) +}; void ffInitKernelOptions(FFKernelOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_KERNEL_MODULE_NAME, - "Print system kernel version", - ffParseKernelCommandOptions, - ffParseKernelJsonObject, - ffPrintKernel, - ffGenerateKernelJsonResult, - ffPrintKernelHelpFormat, - ffGenerateKernelJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/keyboard/keyboard.c b/src/modules/keyboard/keyboard.c index fcf5eba8b..bea387a62 100644 --- a/src/modules/keyboard/keyboard.c +++ b/src/modules/keyboard/keyboard.c @@ -5,8 +5,6 @@ #include "modules/keyboard/keyboard.h" #include "util/stringUtils.h" -#define FF_KEYBOARD_NUM_FORMAT_ARGS 2 - static void printDevice(FFKeyboardOptions* options, const FFKeyboardDevice* device, uint8_t index) { if(options->moduleArgs.outputFormat.length == 0) @@ -16,7 +14,7 @@ static void printDevice(FFKeyboardOptions* options, const FFKeyboardDevice* devi } else { - FF_PRINT_FORMAT_CHECKED(FF_KEYBOARD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_KEYBOARD_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_KEYBOARD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(device->name, "name"), FF_FORMAT_ARG(device->serial, "serial"), })); @@ -112,27 +110,23 @@ void ffGenerateKeyboardJsonResult(FF_MAYBE_UNUSED FFKeyboardOptions* options, yy } } -void ffPrintKeyboardHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_KEYBOARD_MODULE_NAME, "{1} ({3})", FF_KEYBOARD_NUM_FORMAT_ARGS, ((const char* []) { - "Name - name", - "Serial number - serial", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_KEYBOARD_MODULE_NAME, + .description = "List (connected) keyboards", + .parseCommandOptions = (void*) ffParseKeyboardCommandOptions, + .parseJsonObject = (void*) ffParseKeyboardJsonObject, + .printModule = (void*) ffPrintKeyboard, + .generateJsonResult = (void*) ffGenerateKeyboardJsonResult, + .generateJsonConfig = (void*) ffGenerateKeyboardJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Name", "name"}, + {"Serial number", "serial"}, + })) +}; void ffInitKeyboardOptions(FFKeyboardOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_KEYBOARD_MODULE_NAME, - "List connected keyboards", - ffParseKeyboardCommandOptions, - ffParseKeyboardJsonObject, - ffPrintKeyboard, - ffGenerateKeyboardJsonResult, - ffPrintKeyboardHelpFormat, - ffGenerateKeyboardJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/lm/lm.c b/src/modules/lm/lm.c index 12500821a..ff5fb5f9c 100644 --- a/src/modules/lm/lm.c +++ b/src/modules/lm/lm.c @@ -4,8 +4,6 @@ #include "modules/lm/lm.h" #include "util/stringUtils.h" -#define FF_LM_NUM_FORMAT_ARGS 3 - void ffPrintLM(FFLMOptions* options) { FFLMResult result; @@ -38,7 +36,7 @@ void ffPrintLM(FFLMOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_LM_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(result.service, "service"), FF_FORMAT_ARG(result.type, "type"), FF_FORMAT_ARG(result.version, "version"), @@ -115,28 +113,24 @@ void ffGenerateLMJsonResult(FF_MAYBE_UNUSED FFLMOptions* options, yyjson_mut_doc ffStrbufDestroy(&result.version); } -void ffPrintLMHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LM_MODULE_NAME, "{1} {3} ({2})", FF_LM_NUM_FORMAT_ARGS, ((const char* []) { - "LM service - service", - "LM type - type", - "LM version - version" - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_LM_MODULE_NAME, + .description = "Print login manager (desktop manager) name and version", + .parseCommandOptions = (void*) ffParseLMCommandOptions, + .parseJsonObject = (void*) ffParseLMJsonObject, + .printModule = (void*) ffPrintLM, + .generateJsonResult = (void*) ffGenerateLMJsonResult, + .generateJsonConfig = (void*) ffGenerateLMJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"LM service", "service"}, + {"LM type", "type"}, + {"LM version", "version"}, + })) +}; void ffInitLMOptions(FFLMOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_LM_MODULE_NAME, - "Print login manager (desktop manager) name and version", - ffParseLMCommandOptions, - ffParseLMJsonObject, - ffPrintLM, - ffGenerateLMJsonResult, - ffPrintLMHelpFormat, - ffGenerateLMJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰧨"); } diff --git a/src/modules/loadavg/loadavg.c b/src/modules/loadavg/loadavg.c index 27e74a98e..f42d04e12 100644 --- a/src/modules/loadavg/loadavg.c +++ b/src/modules/loadavg/loadavg.c @@ -6,8 +6,6 @@ #include "modules/loadavg/loadavg.h" #include "util/stringUtils.h" -#define FF_LOADAVG_NUM_FORMAT_ARGS 3 - void ffPrintLoadavg(FFLoadavgOptions* options) { double result[3] = { 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0 }; @@ -48,7 +46,7 @@ void ffPrintLoadavg(FFLoadavgOptions* options) else { ffStrbufClear(&buffer); - FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, 3, ((FFformatarg[]){ + FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, ((FFformatarg[]) { FF_FORMAT_ARG(index, "index"), FF_FORMAT_ARG(duration, "duration"), FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), @@ -84,7 +82,7 @@ void ffPrintLoadavg(FFLoadavgOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_LOADAVG_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_LOADAVG_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_LOADAVG_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(result[0], "loadavg1"), FF_FORMAT_ARG(result[1], "loadavg2"), FF_FORMAT_ARG(result[2], "loadavg3"), @@ -181,28 +179,24 @@ void ffGenerateLoadavgJsonResult(FF_MAYBE_UNUSED FFLoadavgOptions* options, yyjs yyjson_mut_arr_add_real(doc, arr, result[i]); } -void ffPrintLoadavgHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LOADAVG_MODULE_NAME, "{1}, {2}, {3}", FF_LOADAVG_NUM_FORMAT_ARGS, ((const char* []) { - "Load average over 1min - loadavg1", - "Load average over 5min - loadavg2", - "Load average over 15min - loadavg3", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_LOADAVG_MODULE_NAME, + .description = "Print system load averages", + .parseCommandOptions = (void*) ffParseLoadavgCommandOptions, + .parseJsonObject = (void*) ffParseLoadavgJsonObject, + .printModule = (void*) ffPrintLoadavg, + .generateJsonResult = (void*) ffGenerateLoadavgJsonResult, + .generateJsonConfig = (void*) ffGenerateLoadavgJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Load average over 1min", "loadavg1"}, + {"Load average over 5min", "loadavg2"}, + {"Load average over 15min", "loadavg3"}, + })) +}; void ffInitLoadavgOptions(FFLoadavgOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_LOADAVG_MODULE_NAME, - "Print system load averages", - ffParseLoadavgCommandOptions, - ffParseLoadavgJsonObject, - ffPrintLoadavg, - ffGenerateLoadavgJsonResult, - ffPrintLoadavgHelpFormat, - ffGenerateLoadavgJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); options->percent = (FFPercentageModuleConfig) { 50, 80, 0 }; diff --git a/src/modules/locale/locale.c b/src/modules/locale/locale.c index cfd417761..1849343b3 100644 --- a/src/modules/locale/locale.c +++ b/src/modules/locale/locale.c @@ -4,8 +4,6 @@ #include "modules/locale/locale.h" #include "util/stringUtils.h" -#define FF_LOCALE_NUM_FORMAT_ARGS 1 - void ffPrintLocale(FFLocaleOptions* options) { FF_STRBUF_AUTO_DESTROY locale = ffStrbufCreate(); @@ -24,7 +22,7 @@ void ffPrintLocale(FFLocaleOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_LOCALE_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(locale, "result") })); } @@ -79,26 +77,22 @@ void ffGenerateLocaleJsonResult(FF_MAYBE_UNUSED FFLocaleOptions* options, yyjson yyjson_mut_obj_add_strbuf(doc, module, "result", &locale); } -void ffPrintLocaleHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LOCALE_MODULE_NAME, "{1}", FF_LOCALE_NUM_FORMAT_ARGS, ((const char* []) { - "Locale code - result" - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_LOCALE_MODULE_NAME, + .description = "Print system locale name", + .parseCommandOptions = (void*) ffParseLocaleCommandOptions, + .parseJsonObject = (void*) ffParseLocaleJsonObject, + .printModule = (void*) ffPrintLocale, + .generateJsonResult = (void*) ffGenerateLocaleJsonResult, + .generateJsonConfig = (void*) ffGenerateLocaleJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Locale code", "result"}, + })) +}; void ffInitLocaleOptions(FFLocaleOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_LOCALE_MODULE_NAME, - "Print system locale name", - ffParseLocaleCommandOptions, - ffParseLocaleJsonObject, - ffPrintLocale, - ffGenerateLocaleJsonResult, - ffPrintLocaleHelpFormat, - ffGenerateLocaleJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index 9e3f88e1b..d8da04692 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -5,7 +5,6 @@ #include "util/stringUtils.h" #define FF_LOCALIP_DISPLAY_NAME "Local IP" -#define FF_LOCALIP_NUM_FORMAT_ARGS 8 #pragma GCC diagnostic ignored "-Wsign-conversion" static int sortIps(const FFLocalIpResult* left, const FFLocalIpResult* right) @@ -25,7 +24,7 @@ static void formatKey(const FFLocalIpOptions* options, FFLocalIpResult* ip, uint else { ffStrbufClear(key); - FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 4, ((FFformatarg[]){ + FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, ((FFformatarg[]) { FF_FORMAT_ARG(index, "index"), FF_FORMAT_ARG(ip->name, "name"), FF_FORMAT_ARG(ip->mac, "mac"), @@ -149,7 +148,7 @@ void ffPrintLocalIp(FFLocalIpOptions* options) else ffStrbufSetF(&speedStr, "%u Mbps", (unsigned) ip->speed); } - FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_LOCALIP_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]){ FF_FORMAT_ARG(ip->ipv4, "ipv4"), FF_FORMAT_ARG(ip->ipv6, "ipv6"), FF_FORMAT_ARG(ip->mac, "mac"), @@ -500,33 +499,29 @@ void ffGenerateLocalIpJsonResult(FF_MAYBE_UNUSED FFLocalIpOptions* options, yyjs } } -void ffPrintLocalIpHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LOCALIP_MODULE_NAME, "{1}", FF_LOCALIP_NUM_FORMAT_ARGS, ((const char* []) { - "Local IPv4 address - ipv4", - "Local IPv6 address - ipv6", - "Physical (MAC) address - mac", - "Interface name - ifname", - "Is default route - is-default-route", - "MTU size in bytes - mtu", - "Link speed (formatted) - speed", - "Interface flags - flags", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_LOCALIP_MODULE_NAME, + .description = "List local IP addresses (v4 or v6), MAC addresses, etc", + .parseCommandOptions = (void*) ffParseLocalIpCommandOptions, + .parseJsonObject = (void*) ffParseLocalIpJsonObject, + .printModule = (void*) ffPrintLocalIp, + .generateJsonResult = (void*) ffGenerateLocalIpJsonResult, + .generateJsonConfig = (void*) ffGenerateLocalIpJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"IPv4 address", "ipv4"}, + {"IPv6 address", "ipv6"}, + {"MAC address", "mac"}, + {"Interface name", "ifname"}, + {"Is default route", "is-default-route"}, + {"MTU size in bytes", "mtu"}, + {"Link speed (formatted)", "speed"}, + {"Interface flags", "flags"}, + })) +}; void ffInitLocalIpOptions(FFLocalIpOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_LOCALIP_MODULE_NAME, - "List local IP addresses (v4 or v6), MAC addresses, etc", - ffParseLocalIpCommandOptions, - ffParseLocalIpJsonObject, - ffPrintLocalIp, - ffGenerateLocalIpJsonResult, - ffPrintLocalIpHelpFormat, - ffGenerateLocalIpJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰩟"); options->showType = FF_LOCALIP_TYPE_IPV4_BIT | FF_LOCALIP_TYPE_PREFIX_LEN_BIT diff --git a/src/modules/media/media.c b/src/modules/media/media.c index a495c9dd4..8bdf13889 100644 --- a/src/modules/media/media.c +++ b/src/modules/media/media.c @@ -6,8 +6,6 @@ #include -#define FF_MEDIA_NUM_FORMAT_ARGS 5 - static inline bool shouldIgnoreChar(char c) { return isblank(c) || c == '-' || c == '.'; @@ -95,7 +93,7 @@ void ffPrintMedia(FFMediaOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_MEDIA_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(songPretty, "combined"), FF_FORMAT_ARG(media->song, "title"), FF_FORMAT_ARG(media->artist, "artist"), @@ -157,30 +155,26 @@ void ffGenerateMediaJsonResult(FF_MAYBE_UNUSED FFMediaOptions* options, yyjson_m yyjson_mut_obj_add_strbuf(doc, obj, "status", &media->status); } -void ffPrintMediaHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MEDIA_MODULE_NAME, "{3} - {1} ({5})", FF_MEDIA_NUM_FORMAT_ARGS, ((const char* []) { - "Pretty media name - combined", - "Media name - title", - "Artist name - artist", - "Album name - album", - "Status - status", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_MEDIA_MODULE_NAME, + .description = "Print playing song name", + .parseCommandOptions = (void*) ffParseMediaCommandOptions, + .parseJsonObject = (void*) ffParseMediaJsonObject, + .printModule = (void*) ffPrintMedia, + .generateJsonResult = (void*) ffGenerateMediaJsonResult, + .generateJsonConfig = (void*) ffGenerateMediaJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Pretty media name", "combined"}, + {"Media name", "title"}, + {"Artist name", "artist"}, + {"Album name", "album"}, + {"Status", "status"}, + })) +}; void ffInitMediaOptions(FFMediaOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_MEDIA_MODULE_NAME, - "Print playing song name", - ffParseMediaCommandOptions, - ffParseMediaJsonObject, - ffPrintMedia, - ffGenerateMediaJsonResult, - ffPrintMediaHelpFormat, - ffGenerateMediaJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/memory/memory.c b/src/modules/memory/memory.c index 8cad52839..8d395a0e8 100644 --- a/src/modules/memory/memory.c +++ b/src/modules/memory/memory.c @@ -6,8 +6,6 @@ #include "modules/memory/memory.h" #include "util/stringUtils.h" -#define FF_MEMORY_NUM_FORMAT_ARGS 4 - void ffPrintMemory(FFMemoryOptions* options) { FFMemoryResult storage = {}; @@ -64,7 +62,7 @@ void ffPrintMemory(FFMemoryOptions* options) if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) ffPercentAppendBar(&percentageBar, percentage, options->percent, &options->moduleArgs); - FF_PRINT_FORMAT_CHECKED(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_MEMORY_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(usedPretty, "used"), FF_FORMAT_ARG(totalPretty, "total"), FF_FORMAT_ARG(percentageNum, "percentage"), @@ -132,29 +130,25 @@ void ffGenerateMemoryJsonResult(FF_MAYBE_UNUSED FFMemoryOptions* options, yyjson yyjson_mut_obj_add_uint(doc, obj, "used", storage.bytesUsed); } -void ffPrintMemoryHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MEMORY_MODULE_NAME, "{1} / {2} ({3})", FF_MEMORY_NUM_FORMAT_ARGS, ((const char* []) { - "Used size - used", - "Total size - total", - "Percentage used (num) - percentage", - "Percentage used (bar) - percentage-bar", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_MEMORY_MODULE_NAME, + .description = "Print system memory usage info", + .parseCommandOptions = (void*) ffParseMemoryCommandOptions, + .parseJsonObject = (void*) ffParseMemoryJsonObject, + .printModule = (void*) ffPrintMemory, + .generateJsonResult = (void*) ffGenerateMemoryJsonResult, + .generateJsonConfig = (void*) ffGenerateMemoryJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Used size", "used"}, + {"Total size", "total"}, + {"Percentage used (num)", "percentage"}, + {"Percentage used (bar)", "percentage-bar"}, + })) +}; void ffInitMemoryOptions(FFMemoryOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_MEMORY_MODULE_NAME, - "Print system memory usage info", - ffParseMemoryCommandOptions, - ffParseMemoryJsonObject, - ffPrintMemory, - ffGenerateMemoryJsonResult, - ffPrintMemoryHelpFormat, - ffGenerateMemoryJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); options->percent = (FFPercentageModuleConfig) { 50, 80, 0 }; } diff --git a/src/modules/monitor/monitor.c b/src/modules/monitor/monitor.c index 93ce917db..1e0255dbe 100644 --- a/src/modules/monitor/monitor.c +++ b/src/modules/monitor/monitor.c @@ -6,8 +6,6 @@ #include -#define FF_MONITOR_NUM_FORMAT_ARGS 12 - void ffPrintMonitor(FFMonitorOptions* options) { const FFDisplayServerResult* result = ffConnectDisplayServer(); @@ -36,7 +34,7 @@ void ffPrintMonitor(FFMonitorOptions* options) else { uint32_t moduleIndex = result->displays.length == 1 ? 0 : index + 1; - FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){ + FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) { FF_FORMAT_ARG(moduleIndex, "index"), FF_FORMAT_ARG(display->name, "name"), FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), @@ -67,7 +65,7 @@ void ffPrintMonitor(FFMonitorOptions* options) else buf[0] = '\0'; - FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_MONITOR_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) { FF_FORMAT_ARG(display->name, "name"), FF_FORMAT_ARG(display->width, "width"), FF_FORMAT_ARG(display->height, "height"), @@ -128,37 +126,33 @@ void ffGenerateMonitorJsonResult(FF_MAYBE_UNUSED FFMonitorOptions* options, yyjs yyjson_mut_obj_add_str(doc, module, "error", "Monitor module is an alias of Display module"); } -void ffPrintMonitorHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MONITOR_MODULE_NAME, "{2}x{3} px - {4}x{5} mm ({6} inches, {7} ppi)", FF_MONITOR_NUM_FORMAT_ARGS, ((const char* []) { - "Display name - name", - "Native resolution width in pixels - width", - "Native resolution height in pixels - height", - "Physical width in millimeters - physical-width", - "Physical height in millimeters - physical-height", - "Physical diagonal length in inches - inch", - "Pixels per inch (PPI) - ppi", - "Year of manufacturing - manufacture-year", - "Nth week of manufacturing in the year - manufacture-week", - "Serial number - serial", - "Maximum refresh rate in Hz - refresh-rate", - "True if the display is HDR compatible - hdr-compatible", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_MONITOR_MODULE_NAME, + .description = "Alias of Display module", + .parseCommandOptions = (void*) ffParseMonitorCommandOptions, + .parseJsonObject = (void*) ffParseMonitorJsonObject, + .printModule = (void*) ffPrintMonitor, + .generateJsonResult = (void*) ffGenerateMonitorJsonResult, + .generateJsonConfig = (void*) ffGenerateMonitorJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Display name", "name"}, + {"Native resolution width in pixels", "width"}, + {"Native resolution height in pixels", "height"}, + {"Physical width in millimeters", "physical-width"}, + {"Physical height in millimeters", "physical-height"}, + {"Physical diagonal length in inches", "inch"}, + {"Pixels per inch (PPI)", "ppi"}, + {"Year of manufacturing", "manufacture-year"}, + {"Nth week of manufacturing in the year", "manufacture-week"}, + {"Serial number", "serial"}, + {"Maximum refresh rate in Hz", "refresh-rate"}, + {"True if the display is HDR compatible", "hdr-compatible"}, + })) +}; void ffInitMonitorOptions(FFMonitorOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_MONITOR_MODULE_NAME, - "Alias of Display module", - ffParseMonitorCommandOptions, - ffParseMonitorJsonObject, - ffPrintMonitor, - ffGenerateMonitorJsonResult, - ffPrintMonitorHelpFormat, - ffGenerateMonitorJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰹑"); } diff --git a/src/modules/mouse/mouse.c b/src/modules/mouse/mouse.c index 27b749f47..f2dbd9def 100644 --- a/src/modules/mouse/mouse.c +++ b/src/modules/mouse/mouse.c @@ -5,8 +5,6 @@ #include "modules/mouse/mouse.h" #include "util/stringUtils.h" -#define FF_MOUSE_NUM_FORMAT_ARGS 2 - static void printDevice(FFMouseOptions* options, const FFMouseDevice* device, uint8_t index) { if(options->moduleArgs.outputFormat.length == 0) @@ -16,7 +14,7 @@ static void printDevice(FFMouseOptions* options, const FFMouseDevice* device, ui } else { - FF_PRINT_FORMAT_CHECKED(FF_MOUSE_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_MOUSE_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_MOUSE_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(device->name, "name"), FF_FORMAT_ARG(device->serial, "serial"), })); @@ -112,27 +110,23 @@ void ffGenerateMouseJsonResult(FF_MAYBE_UNUSED FFMouseOptions* options, yyjson_m } } -void ffPrintMouseHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MOUSE_MODULE_NAME, "{1} ({3})", FF_MOUSE_NUM_FORMAT_ARGS, ((const char* []) { - "Name - name", - "Serial number - serial", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_MOUSE_MODULE_NAME, + .description = "List connected mouses", + .parseCommandOptions = (void*) ffParseMouseCommandOptions, + .parseJsonObject = (void*) ffParseMouseJsonObject, + .printModule = (void*) ffPrintMouse, + .generateJsonResult = (void*) ffGenerateMouseJsonResult, + .generateJsonConfig = (void*) ffGenerateMouseJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Mouse name", "name"}, + {"Mouse serial number", "serial"}, + })) +}; void ffInitMouseOptions(FFMouseOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_MOUSE_MODULE_NAME, - "List connected mouses", - ffParseMouseCommandOptions, - ffParseMouseJsonObject, - ffPrintMouse, - ffGenerateMouseJsonResult, - ffPrintMouseHelpFormat, - ffGenerateMouseJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰍽"); } diff --git a/src/modules/netio/netio.c b/src/modules/netio/netio.c index 6dd3e8a98..50281338e 100644 --- a/src/modules/netio/netio.c +++ b/src/modules/netio/netio.c @@ -6,7 +6,6 @@ #include "util/stringUtils.h" #define FF_NETIO_DISPLAY_NAME "Network IO" -#define FF_NETIO_NUM_FORMAT_ARGS 12 static int sortInfs(const FFNetIOResult* left, const FFNetIOResult* right) { @@ -25,7 +24,7 @@ static void formatKey(const FFNetIOOptions* options, FFNetIOResult* inf, uint32_ else { ffStrbufClear(key); - FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 3, ((FFformatarg[]){ + FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, ((FFformatarg[]){ FF_FORMAT_ARG(index, "index"), FF_FORMAT_ARG(inf->name, "name"), FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), @@ -80,7 +79,7 @@ void ffPrintNetIO(FFNetIOOptions* options) ffParseSize(inf->txBytes, &buffer2); if (!options->detectTotal) ffStrbufAppendS(&buffer2, "/s"); - FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_NETIO_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]){ FF_FORMAT_ARG(buffer, "rx-size"), FF_FORMAT_ARG(buffer2, "tx-size"), FF_FORMAT_ARG(inf->name, "ifname"), @@ -229,37 +228,33 @@ void ffGenerateNetIOJsonResult(FFNetIOOptions* options, yyjson_mut_doc* doc, yyj } } -void ffPrintNetIOHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_NETIO_MODULE_NAME, "{1} (IN) - {2} (OUT)", FF_NETIO_NUM_FORMAT_ARGS, ((const char* []) { - "Size of data received [per second] (formatted) - rx-size", - "Size of data sent [per second] (formatted) - tx-size", - "Interface name - ifname", - "Is default route - is-default-route", - "Size of data received [per second] (in bytes) - rx-bytes", - "Size of data sent [per second] (in bytes) - tx-bytes", - "Number of packets received [per second] - rx-packets", - "Number of packets sent [per second] - tx-packets", - "Number of errors received [per second] - rx-errors", - "Number of errors sent [per second] - tx-errors", - "Number of packets dropped when receiving [per second] - rx-drops", - "Number of packets dropped when sending [per second] - tx-drops", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_NETIO_MODULE_NAME, + .description = "Print network I/O throughput", + .parseCommandOptions = (void*) ffParseNetIOCommandOptions, + .parseJsonObject = (void*) ffParseNetIOJsonObject, + .printModule = (void*) ffPrintNetIO, + .generateJsonResult = (void*) ffGenerateNetIOJsonResult, + .generateJsonConfig = (void*) ffGenerateNetIOJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Size of data received [per second] (formatted)", "rx-size"}, + {"Size of data sent [per second] (formatted)", "tx-size"}, + {"Interface name", "ifname"}, + {"Is default route", "is-default-route"}, + {"Size of data received [per second] (in bytes)", "rx-bytes"}, + {"Size of data sent [per second] (in bytes)", "tx-bytes"}, + {"Number of packets received [per second]", "rx-packets"}, + {"Number of packets sent [per second]", "tx-packets"}, + {"Number of errors received [per second]", "rx-errors"}, + {"Number of errors sent [per second]", "tx-errors"}, + {"Number of packets dropped when receiving [per second]", "rx-drops"}, + {"Number of packets dropped when sending [per second]", "tx-drops"}, + })) +}; void ffInitNetIOOptions(FFNetIOOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_NETIO_MODULE_NAME, - "Print network I/O throughput", - ffParseNetIOCommandOptions, - ffParseNetIOJsonObject, - ffPrintNetIO, - ffGenerateNetIOJsonResult, - ffPrintNetIOHelpFormat, - ffGenerateNetIOJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰾆"); ffStrbufInit(&options->namePrefix); diff --git a/src/modules/opencl/opencl.c b/src/modules/opencl/opencl.c index 30f3c716c..bcf2deae6 100644 --- a/src/modules/opencl/opencl.c +++ b/src/modules/opencl/opencl.c @@ -5,8 +5,6 @@ #include "modules/opencl/opencl.h" #include "util/stringUtils.h" -#define FF_OPENCL_NUM_FORMAT_ARGS 3 - void ffPrintOpenCL(FFOpenCLOptions* options) { FFOpenCLResult* result = ffDetectOpenCL(); @@ -24,7 +22,7 @@ void ffPrintOpenCL(FFOpenCLOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_OPENCL_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(result->version, "version"), FF_FORMAT_ARG(result->name, "name"), FF_FORMAT_ARG(result->vendor, "vendor"), @@ -130,28 +128,24 @@ void ffGenerateOpenCLJsonResult(FF_MAYBE_UNUSED FFOpenCLOptions* options, yyjson } } -void ffPrintOpenCLHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_OPENCL_MODULE_NAME, "{1}", FF_OPENCL_NUM_FORMAT_ARGS, ((const char* []) { - "Platform version - version", - "Platform name - name", - "Platform vendor - vendor", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_OPENCL_MODULE_NAME, + .description = "Print highest OpenCL version supported by the GPU", + .parseCommandOptions = (void*) ffParseOpenCLCommandOptions, + .parseJsonObject = (void*) ffParseOpenCLJsonObject, + .printModule = (void*) ffPrintOpenCL, + .generateJsonResult = (void*) ffGenerateOpenCLJsonResult, + .generateJsonConfig = (void*) ffGenerateOpenCLJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Platform version", "version"}, + {"Platform name", "name"}, + {"Platform vendor", "vendor"}, + })) +}; void ffInitOpenCLOptions(FFOpenCLOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_OPENCL_MODULE_NAME, - "Print highest OpenCL version supported by the GPU", - ffParseOpenCLCommandOptions, - ffParseOpenCLJsonObject, - ffPrintOpenCL, - ffGenerateOpenCLJsonResult, - ffPrintOpenCLHelpFormat, - ffGenerateOpenCLJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/opengl/opengl.c b/src/modules/opengl/opengl.c index d00c87e55..8aeeb9c5d 100644 --- a/src/modules/opengl/opengl.c +++ b/src/modules/opengl/opengl.c @@ -4,8 +4,6 @@ #include "modules/opengl/opengl.h" #include "util/stringUtils.h" -#define FF_OPENGL_NUM_FORMAT_ARGS 5 - void ffPrintOpenGL(FFOpenGLOptions* options) { FFOpenGLResult result; @@ -29,7 +27,7 @@ void ffPrintOpenGL(FFOpenGLOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_OPENGL_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(result.version, "version"), FF_FORMAT_ARG(result.renderer, "renderer"), FF_FORMAT_ARG(result.vendor, "vendor"), @@ -159,30 +157,26 @@ void ffGenerateOpenGLJsonResult(FF_MAYBE_UNUSED FFOpenGLOptions* options, yyjson ffStrbufDestroy(&result.library); } -void ffPrintOpenGLHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_OPENGL_MODULE_NAME, "{1}", FF_OPENGL_NUM_FORMAT_ARGS, ((const char* []) { - "version - version", - "renderer - renderer", - "vendor - vendor", - "shading language version - slv", - "ogl library used - library", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_OPENGL_MODULE_NAME, + .description = "Print highest OpenGL version supported by the GPU", + .parseCommandOptions = (void*) ffParseOpenGLCommandOptions, + .parseJsonObject = (void*) ffParseOpenGLJsonObject, + .printModule = (void*) ffPrintOpenGL, + .generateJsonResult = (void*) ffGenerateOpenGLJsonResult, + .generateJsonConfig = (void*) ffGenerateOpenGLJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"OpenGL version", "version"}, + {"OpenGL renderer", "renderer"}, + {"OpenGL vendor", "vendor"}, + {"OpenGL shading language version", "slv"}, + {"OpenGL library used", "library"}, + })) +}; void ffInitOpenGLOptions(FFOpenGLOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_OPENGL_MODULE_NAME, - "Print highest OpenGL version supported by the GPU", - ffParseOpenGLCommandOptions, - ffParseOpenGLJsonObject, - ffPrintOpenGL, - ffGenerateOpenGLJsonResult, - ffPrintOpenGLHelpFormat, - ffGenerateOpenGLJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); options->library = FF_OPENGL_LIBRARY_AUTO; diff --git a/src/modules/os/os.c b/src/modules/os/os.c index cc488382f..10df93b0f 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -7,8 +7,6 @@ #include -#define FF_OS_NUM_FORMAT_ARGS 12 - static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result) { //Create the basic output @@ -111,7 +109,7 @@ void ffPrintOS(FFOSOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_OS_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(instance.state.platform.sysinfo.name, "sysname"), FF_FORMAT_ARG(os->name, "name"), FF_FORMAT_ARG(os->prettyName, "pretty-name"), @@ -186,37 +184,33 @@ void ffGenerateOSJsonResult(FF_MAYBE_UNUSED FFOSOptions* options, yyjson_mut_doc yyjson_mut_obj_add_strbuf(doc, obj, "versionID", &os->versionID); } -void ffPrintOSHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_OS_MODULE_NAME, "{3} {10} {12}", FF_OS_NUM_FORMAT_ARGS, ((const char* []) { - "Name of the kernel (Linux, WIN32_NT, Darwin, FreeBSD) - sysname", - "Name of the OS - name", - "Pretty name of the OS - pretty-name", - "ID of the OS - id", - "ID like of the OS - id-like", - "Variant of the OS - variant", - "Variant ID of the OS - variant-id", - "Version of the OS - version", - "Version ID of the OS - version-id", - "Version codename of the OS - codename", - "Build ID of the OS - build-id", - "Architecture of the OS - arch", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_OS_MODULE_NAME, + .description = "Print operating system name and version", + .parseCommandOptions = (void*) ffParseOSCommandOptions, + .parseJsonObject = (void*) ffParseOSJsonObject, + .printModule = (void*) ffPrintOS, + .generateJsonResult = (void*) ffGenerateOSJsonResult, + .generateJsonConfig = (void*) ffGenerateOSJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Name of the kernel", "sysname"}, + {"Name of the OS", "name"}, + {"Pretty name of the OS", "pretty-name"}, + {"ID of the OS", "id"}, + {"ID like of the OS", "id-like"}, + {"Variant of the OS", "variant"}, + {"Variant ID of the OS", "variant-id"}, + {"Version of the OS", "version"}, + {"Version ID of the OS", "version-id"}, + {"Version codename of the OS", "codename"}, + {"Build ID of the OS", "build-id"}, + {"Architecture of the OS", "arch"}, + })) +}; void ffInitOSOptions(FFOSOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_OS_MODULE_NAME, - "Print operating system name and version", - ffParseOSCommandOptions, - ffParseOSJsonObject, - ffPrintOS, - ffGenerateOSJsonResult, - ffPrintOSHelpFormat, - ffGenerateOSJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, #ifdef _WIN32 "" diff --git a/src/modules/packages/packages.c b/src/modules/packages/packages.c index 3241b714d..480bf193a 100644 --- a/src/modules/packages/packages.c +++ b/src/modules/packages/packages.c @@ -4,8 +4,6 @@ #include "modules/packages/packages.h" #include "util/stringUtils.h" -#define FF_PACKAGES_NUM_FORMAT_ARGS 40 - void ffPrintPackages(FFPackagesOptions* options) { FFPackagesResult counts = {}; @@ -84,7 +82,7 @@ void ffPrintPackages(FFPackagesOptions* options) uint32_t flatpakAll = counts.flatpakSystem + counts.flatpakUser; uint32_t brewAll = counts.brew + counts.brewCask; uint32_t guixAll = counts.guixSystem + counts.guixUser + counts.guixHome; - FF_PRINT_FORMAT_CHECKED(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PACKAGES_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(counts.all, "all"), FF_FORMAT_ARG(counts.pacman, "pacman"), FF_FORMAT_ARG(counts.pacmanBranch, "pacman-branch"), @@ -437,65 +435,61 @@ void ffGeneratePackagesJsonResult(FF_MAYBE_UNUSED FFPackagesOptions* options, yy yyjson_mut_obj_add_strbuf(doc, obj, "pacmanBranch", &counts.pacmanBranch); } -void ffPrintPackagesHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PACKAGES_MODULE_NAME, "{2} (pacman){?3}[{3}]{?}, {4} (dpkg), {5} (rpm), {6} (emerge), {7} (eopkg), {8} (xbps), {9} (nix-system), {10} (nix-user), {11} (nix-default), {12} (apk), {13} (pkg), {14} (flatpak-system), {15} (flatpack-user), {16} (snap), {17} (brew), {18} (brew-cask), {19} (MacPorts), {20} (scoop), {21} (choco), {22} (pkgtool), {23} (paludis), {24} (winget), {25} (opkg), {26} (am), {27} (sorcery), {28} (lpkg), {29} (lpkgbuild), {30} (guix-system), {31} (guix-user), {32} (guix-home), {33} (linglong), {34} (pacstall), {35} (mport), {36} qi", FF_PACKAGES_NUM_FORMAT_ARGS, ((const char* []) { - "Number of all packages - all", - "Number of pacman packages - pacman", - "Pacman branch on manjaro - pacman-branch", - "Number of dpkg packages - dpkg", - "Number of rpm packages - rpm", - "Number of emerge packages - emerge", - "Number of eopkg packages - eopkg", - "Number of xbps packages - xbps", - "Number of nix-system packages - nix-system", - "Number of nix-user packages - nix-user", - "Number of nix-default packages - nix-default", - "Number of apk packages - apk", - "Number of pkg packages - pkg", - "Number of flatpak-system app packages - flatpak-system", - "Number of flatpak-user app packages - flatpak-user", - "Number of snap packages - snap", - "Number of brew packages - brew", - "Number of brew-cask packages - brew-cask", - "Number of macports packages - macports", - "Number of scoop packages - scoop", - "Number of choco packages - choco", - "Number of pkgtool packages - pkgtool", - "Number of paludis packages - paludis", - "Number of winget packages - winget", - "Number of opkg packages - opkg", - "Number of am packages - am", - "Number of sorcery packages - sorcery", - "Number of lpkg packages - lpkg", - "Number of lpkgbuild packages - lpkgbuild", - "Number of guix-system packages - guix-system", - "Number of guix-user packages - guix-user", - "Number of guix-home packages - guix-home", - "Number of linglong packages - linglong", - "Number of pacstall packages - pacstall", - "Number of mport packages - mport", - "Number of qi packages - qi", - "Total number of all nix packages - nix-all", - "Total number of all flatpak app packages - flatpak-all", - "Total number of all brew packages - brew-all", - "Total number of all guix packages - guix-all", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_PACKAGES_MODULE_NAME, + .description = "List installed package managers and count of installed packages", + .parseCommandOptions = (void*) ffParsePackagesCommandOptions, + .parseJsonObject = (void*) ffParsePackagesJsonObject, + .printModule = (void*) ffPrintPackages, + .generateJsonResult = (void*) ffGeneratePackagesJsonResult, + .generateJsonConfig = (void*) ffGeneratePackagesJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Number of all packages", "all"}, + {"Number of pacman packages", "pacman"}, + {"Pacman branch on manjaro", "pacman-branch"}, + {"Number of dpkg packages", "dpkg"}, + {"Number of rpm packages", "rpm"}, + {"Number of emerge packages", "emerge"}, + {"Number of eopkg packages", "eopkg"}, + {"Number of xbps packages", "xbps"}, + {"Number of nix-system packages", "nix-system"}, + {"Number of nix-user packages", "nix-user"}, + {"Number of nix-default packages", "nix-default"}, + {"Number of apk packages", "apk"}, + {"Number of pkg packages", "pkg"}, + {"Number of flatpak-system app packages", "flatpak-system"}, + {"Number of flatpak-user app packages", "flatpak-user"}, + {"Number of snap packages", "snap"}, + {"Number of brew packages", "brew"}, + {"Number of brew-cask packages", "brew-cask"}, + {"Number of macports packages", "macports"}, + {"Number of scoop packages", "scoop"}, + {"Number of choco packages", "choco"}, + {"Number of pkgtool packages", "pkgtool"}, + {"Number of paludis packages", "paludis"}, + {"Number of winget packages", "winget"}, + {"Number of opkg packages", "opkg"}, + {"Number of am packages", "am"}, + {"Number of sorcery packages", "sorcery"}, + {"Number of lpkg packages", "lpkg"}, + {"Number of lpkgbuild packages", "lpkgbuild"}, + {"Number of guix-system packages", "guix-system"}, + {"Number of guix-user packages", "guix-user"}, + {"Number of guix-home packages", "guix-home"}, + {"Number of linglong packages", "linglong"}, + {"Number of pacstall packages", "pacstall"}, + {"Number of mport packages", "mport"}, + {"Number of qi packages", "qi"}, + {"Total number of all nix packages", "nix-all"}, + {"Total number of all flatpak app packages", "flatpak-all"}, + {"Total number of all brew packages", "brew-all"}, + {"Total number of all guix packages", "guix-all"}, + })) +}; void ffInitPackagesOptions(FFPackagesOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_PACKAGES_MODULE_NAME, - "List installed package managers and count of installed packages", - ffParsePackagesCommandOptions, - ffParsePackagesJsonObject, - ffPrintPackages, - ffGeneratePackagesJsonResult, - ffPrintPackagesHelpFormat, - ffGeneratePackagesJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰏖"); options->disabled = FF_PACKAGES_DISABLE_LIST; diff --git a/src/modules/physicaldisk/physicaldisk.c b/src/modules/physicaldisk/physicaldisk.c index f5ce33bc6..92a6d1b49 100644 --- a/src/modules/physicaldisk/physicaldisk.c +++ b/src/modules/physicaldisk/physicaldisk.c @@ -7,7 +7,6 @@ #include "util/stringUtils.h" #define FF_PHYSICALDISK_DISPLAY_NAME "Physical Disk" -#define FF_PHYSICALDISK_NUM_FORMAT_ARGS 10 static int sortDevices(const FFPhysicalDiskResult* left, const FFPhysicalDiskResult* right) { @@ -23,7 +22,7 @@ static void formatKey(const FFPhysicalDiskOptions* options, FFPhysicalDiskResult else { ffStrbufClear(key); - FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 4, ((FFformatarg[]){ + FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, ((FFformatarg[]){ FF_FORMAT_ARG(index, "index"), FF_FORMAT_ARG(dev->name, "name"), FF_FORMAT_ARG(dev->devPath, "dev-path"), @@ -108,13 +107,13 @@ void ffPrintPhysicalDisk(FFPhysicalDiskOptions* options) ffTempsAppendNum(dev->temperature, &tempStr, options->tempConfig, &options->moduleArgs); if (dev->type & FF_PHYSICALDISK_TYPE_READWRITE) readOnlyType = "Read-write"; - FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_PHYSICALDISK_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]){ FF_FORMAT_ARG(buffer, "size"), FF_FORMAT_ARG(dev->name, "name"), FF_FORMAT_ARG(dev->interconnect, "interconnect"), - FF_FORMAT_ARG(physicalType, "type"), FF_FORMAT_ARG(dev->devPath, "dev-path"), FF_FORMAT_ARG(dev->serial, "serial"), + FF_FORMAT_ARG(physicalType, "physical-type"), FF_FORMAT_ARG(removableType, "removable-type"), FF_FORMAT_ARG(readOnlyType, "readonly-type"), FF_FORMAT_ARG(dev->revision, "revision"), @@ -250,35 +249,31 @@ void ffGeneratePhysicalDiskJsonResult(FFPhysicalDiskOptions* options, yyjson_mut } } -void ffPrintPhysicalDiskHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PHYSICALDISK_MODULE_NAME, "{1} [{6}, {7}, {8}]", FF_PHYSICALDISK_NUM_FORMAT_ARGS, ((const char* []) { - "Device size (formatted) - ", - "Device name", - "Device interconnect type", - "Device raw file path", - "Serial number", - "Device kind (SSD or HDD)", - "Device kind (Removable or Fixed)", - "Device kind (Read-only or Read-write)", - "Product revision", - "Device temperature (formatted)", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_PHYSICALDISK_MODULE_NAME, + .description = "Print physical disk information", + .parseCommandOptions = (void*) ffParsePhysicalDiskCommandOptions, + .parseJsonObject = (void*) ffParsePhysicalDiskJsonObject, + .printModule = (void*) ffPrintPhysicalDisk, + .generateJsonResult = (void*) ffGeneratePhysicalDiskJsonResult, + .generateJsonConfig = (void*) ffGeneratePhysicalDiskJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Device size (formatted)", "size"}, + {"Device name", "name"}, + {"Device interconnect type", "interconnect"}, + {"Device raw file path", "dev-path"}, + {"Serial number", "serial"}, + {"Device kind (SSD or HDD)", "physical-type"}, + {"Device kind (Removable or Fixed)", "removable-type"}, + {"Device kind (Read-only or Read-write)", "readonly-type"}, + {"Product revision", "revision"}, + {"Device temperature (formatted)", "temperature"}, + })) +}; void ffInitPhysicalDiskOptions(FFPhysicalDiskOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_PHYSICALDISK_MODULE_NAME, - "Print physical disk information", - ffParsePhysicalDiskCommandOptions, - ffParsePhysicalDiskJsonObject, - ffPrintPhysicalDisk, - ffGeneratePhysicalDiskJsonResult, - ffPrintPhysicalDiskHelpFormat, - ffGeneratePhysicalDiskJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰋊"); ffStrbufInit(&options->namePrefix); diff --git a/src/modules/physicalmemory/physicalmemory.c b/src/modules/physicalmemory/physicalmemory.c index 747b7e709..2585a054f 100644 --- a/src/modules/physicalmemory/physicalmemory.c +++ b/src/modules/physicalmemory/physicalmemory.c @@ -6,7 +6,6 @@ #include "modules/physicalmemory/physicalmemory.h" #include "util/stringUtils.h" -#define FF_PHYSICALMEMORY_NUM_FORMAT_ARGS 11 #define FF_PHYSICALMEMORY_DISPLAY_NAME "Physical Memory" void ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options) @@ -54,7 +53,7 @@ void ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_PHYSICALMEMORY_DISPLAY_NAME, (uint8_t) i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PHYSICALMEMORY_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_PHYSICALMEMORY_DISPLAY_NAME, (uint8_t) i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(device->size, "bytes"), FF_FORMAT_ARG(prettySize, "size"), FF_FORMAT_ARG(device->maxSpeed, "max-speed"), @@ -154,36 +153,31 @@ void ffGeneratePhysicalMemoryJsonResult(FF_MAYBE_UNUSED FFPhysicalMemoryOptions* } } -void ffPrintPhysicalMemoryHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PHYSICALMEMORY_MODULE_NAME, "{7} {5}-{3}: {2}, running at {4} MT/s", FF_PHYSICALMEMORY_NUM_FORMAT_ARGS, ((const char* []) { - "Size (in bytes) - bytes", - "Size formatted - size", - "Max speed (in MT/s) - max-speed", - "Running speed (in MT/s) - running-speed", - "Type (DDR4, DDR5, etc.) - type", - "Form factor (SODIMM, DIMM, etc.) - form-factor", - "Bank/Device Locator (BANK0/SIMM0, BANK0/SIMM1, etc.) - locator", - "Vendor - vendor", - "Serial number - serial", - "Part number - part-number", - "True if ECC enabled - is-ecc-enabled", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_PHYSICALMEMORY_MODULE_NAME, + .description = "Print system physical memory devices", + .parseCommandOptions = (void*) ffParsePhysicalMemoryCommandOptions, + .parseJsonObject = (void*) ffParsePhysicalMemoryJsonObject, + .printModule = (void*) ffPrintPhysicalMemory, + .generateJsonConfig = (void*) ffGeneratePhysicalMemoryJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Size (in bytes)", "bytes"}, + {"Size formatted", "size"}, + {"Max speed (in MT/s)", "max-speed"}, + {"Running speed (in MT/s)", "running-speed"}, + {"Type (DDR4, DDR5, etc.)", "type"}, + {"Form factor (SODIMM, DIMM, etc.)", "form-factor"}, + {"Bank/Device Locator (BANK0/SIMM0, BANK0/SIMM1, etc.)", "locator"}, + {"Vendor", "vendor"}, + {"Serial number", "serial"}, + {"Part number", "part-number"}, + {"True if ECC enabled", "is-ecc-enabled"}, + })) +}; void ffInitPhysicalMemoryOptions(FFPhysicalMemoryOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_PHYSICALMEMORY_MODULE_NAME, - "Print system physical memory devices", - ffParsePhysicalMemoryCommandOptions, - ffParsePhysicalMemoryJsonObject, - ffPrintPhysicalMemory, - ffGeneratePhysicalMemoryJsonResult, - ffPrintPhysicalMemoryHelpFormat, - ffGeneratePhysicalMemoryJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰑭"); } diff --git a/src/modules/player/player.c b/src/modules/player/player.c index 2dd781a80..c462b3e2a 100644 --- a/src/modules/player/player.c +++ b/src/modules/player/player.c @@ -7,7 +7,6 @@ #include #define FF_PLAYER_DISPLAY_NAME "Media Player" -#define FF_PLAYER_NUM_FORMAT_ARGS 4 void ffPrintPlayer(FFPlayerOptions* options) { @@ -73,7 +72,7 @@ void ffPrintPlayer(FFPlayerOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PLAYER_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(playerPretty, "player"), FF_FORMAT_ARG(media->player, "name"), FF_FORMAT_ARG(media->playerId, "id"), @@ -133,29 +132,25 @@ void ffGeneratePlayerJsonResult(FF_MAYBE_UNUSED FFMediaOptions* options, yyjson_ yyjson_mut_obj_add_strbuf(doc, obj, "url", &media->url); } -void ffPrintPlayerHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PLAYER_MODULE_NAME, "{1}", FF_PLAYER_NUM_FORMAT_ARGS, ((const char* []) { - "Pretty player name - player", - "Player name - name", - "Player Identifier - id", - "URL name - url", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_PLAYER_MODULE_NAME, + .description = "Print music player name", + .parseCommandOptions = (void*) ffParsePlayerCommandOptions, + .parseJsonObject = (void*) ffParsePlayerJsonObject, + .printModule = (void*) ffPrintPlayer, + .generateJsonResult = (void*) ffGeneratePlayerJsonResult, + .generateJsonConfig = (void*) ffGeneratePlayerJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Pretty player name", "player"}, + {"Player name", "name"}, + {"Player Identifier", "id"}, + {"URL name", "url"}, + })) +}; void ffInitPlayerOptions(FFPlayerOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_PLAYER_MODULE_NAME, - "Print music player name", - ffParsePlayerCommandOptions, - ffParsePlayerJsonObject, - ffPrintPlayer, - ffGeneratePlayerJsonResult, - ffPrintPlayerHelpFormat, - ffGeneratePlayerJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰥠"); } diff --git a/src/modules/poweradapter/poweradapter.c b/src/modules/poweradapter/poweradapter.c index 76745e6e1..f99e15783 100644 --- a/src/modules/poweradapter/poweradapter.c +++ b/src/modules/poweradapter/poweradapter.c @@ -5,7 +5,6 @@ #include "util/stringUtils.h" #define FF_POWERADAPTER_DISPLAY_NAME "Power Adapter" -#define FF_POWERADAPTER_NUM_FORMAT_ARGS 6 void ffPrintPowerAdapter(FFPowerAdapterOptions* options) { @@ -38,7 +37,7 @@ void ffPrintPowerAdapter(FFPowerAdapterOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_POWERADAPTER_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(result->watts, "watts"), FF_FORMAT_ARG(result->name, "name"), FF_FORMAT_ARG(result->manufacturer, "manufacturer"), @@ -126,31 +125,27 @@ void ffGeneratePowerAdapterJsonResult(FF_MAYBE_UNUSED FFPowerAdapterOptions* opt } } -void ffPrintPowerAdapterHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_POWERADAPTER_MODULE_NAME, "{1}W", FF_POWERADAPTER_NUM_FORMAT_ARGS, ((const char* []) { - "PowerAdapter watts - watts", - "PowerAdapter name - name", - "PowerAdapter manufacturer - manufacturer", - "PowerAdapter model - model", - "PowerAdapter description - description", - "PowerAdapter serial number - serial", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_POWERADAPTER_MODULE_NAME, + .description = "Print power adapter name and charging watts", + .parseCommandOptions = (void*) ffParsePowerAdapterCommandOptions, + .parseJsonObject = (void*) ffParsePowerAdapterJsonObject, + .printModule = (void*) ffPrintPowerAdapter, + .generateJsonResult = (void*) ffGeneratePowerAdapterJsonResult, + .generateJsonConfig = (void*) ffGeneratePowerAdapterJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Power adapter watts", "watts"}, + {"Power adapter name", "name"}, + {"Power adapter manufacturer", "manufacturer"}, + {"Power adapter model", "model"}, + {"Power adapter description", "description"}, + {"Power adapter serial number", "serial"}, + })) +}; void ffInitPowerAdapterOptions(FFPowerAdapterOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_POWERADAPTER_MODULE_NAME, - "Print power adapter name and charging watts", - ffParsePowerAdapterCommandOptions, - ffParsePowerAdapterJsonObject, - ffPrintPowerAdapter, - ffGeneratePowerAdapterJsonResult, - ffPrintPowerAdapterHelpFormat, - ffGeneratePowerAdapterJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰚥"); } diff --git a/src/modules/processes/processes.c b/src/modules/processes/processes.c index 8c4d4865b..3f06803e0 100644 --- a/src/modules/processes/processes.c +++ b/src/modules/processes/processes.c @@ -4,8 +4,6 @@ #include "modules/processes/processes.h" #include "util/stringUtils.h" -#define FF_PROCESSES_NUM_FORMAT_ARGS 1 - void ffPrintProcesses(FFProcessesOptions* options) { uint32_t numProcesses = 0; @@ -25,7 +23,7 @@ void ffPrintProcesses(FFProcessesOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PROCESSES_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(numProcesses, "result") })); } @@ -80,26 +78,22 @@ void ffGenerateProcessesJsonResult(FF_MAYBE_UNUSED FFProcessesOptions* options, yyjson_mut_obj_add_uint(doc, module, "result", result); } -void ffPrintProcessesHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PROCESSES_MODULE_NAME, "{1}", FF_PROCESSES_NUM_FORMAT_ARGS, (const char* []) { - "Proecess count - result" - }); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_PROCESSES_MODULE_NAME, + .description = "Print number of running processes", + .parseCommandOptions = (void*) ffParseProcessesCommandOptions, + .parseJsonObject = (void*) ffParseProcessesJsonObject, + .printModule = (void*) ffPrintProcesses, + .generateJsonResult = (void*) ffGenerateProcessesJsonResult, + .generateJsonConfig = (void*) ffGenerateProcessesJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Process count", "result"} + })) +}; void ffInitProcessesOptions(FFProcessesOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_PROCESSES_MODULE_NAME, - "Count running processes", - ffParseProcessesCommandOptions, - ffParseProcessesJsonObject, - ffPrintProcesses, - ffGenerateProcessesJsonResult, - ffPrintProcessesHelpFormat, - ffGenerateProcessesJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/publicip/publicip.c b/src/modules/publicip/publicip.c index 110dea8e0..71163fbd1 100644 --- a/src/modules/publicip/publicip.c +++ b/src/modules/publicip/publicip.c @@ -5,7 +5,6 @@ #include "util/stringUtils.h" #define FF_PUBLICIP_DISPLAY_NAME "Public IP" -#define FF_PUBLICIP_NUM_FORMAT_ARGS 2 void ffPrintPublicIp(FFPublicIpOptions* options) { @@ -30,7 +29,7 @@ void ffPrintPublicIp(FFPublicIpOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PUBLICIP_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(result.ip, "ip"), FF_FORMAT_ARG(result.location, "location"), })); @@ -141,27 +140,23 @@ void ffGeneratePublicIpJsonResult(FFPublicIpOptions* options, yyjson_mut_doc* do ffStrbufDestroy(&result.location); } -void ffPrintPublicIpHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PUBLICIP_MODULE_NAME, "{1} ({2})", FF_PUBLICIP_NUM_FORMAT_ARGS, ((const char* []) { - "Public IP address - ip", - "Location - location", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_PUBLICIP_MODULE_NAME, + .description = "Print your public IP address, etc", + .parseCommandOptions = (void*) ffParsePublicIpCommandOptions, + .parseJsonObject = (void*) ffParsePublicIpJsonObject, + .printModule = (void*) ffPrintPublicIp, + .generateJsonResult = (void*) ffGeneratePublicIpJsonResult, + .generateJsonConfig = (void*) ffGeneratePublicIpJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Public IP address", "ip"}, + {"Location", "location"}, + })) +}; void ffInitPublicIpOptions(FFPublicIpOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_PUBLICIP_MODULE_NAME, - "Print your public IP address, etc", - ffParsePublicIpCommandOptions, - ffParsePublicIpJsonObject, - ffPrintPublicIp, - ffGeneratePublicIpJsonResult, - ffPrintPublicIpHelpFormat, - ffGeneratePublicIpJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰩠"); ffStrbufInit(&options->url); diff --git a/src/modules/separator/separator.c b/src/modules/separator/separator.c index 90a4e2096..28ecdac8a 100644 --- a/src/modules/separator/separator.c +++ b/src/modules/separator/separator.c @@ -178,19 +178,23 @@ void ffGenerateSeparatorJsonConfig(FFSeparatorOptions* options, yyjson_mut_doc* yyjson_mut_obj_add_strbuf(doc, module, "string", &options->string); } +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_SEPARATOR_MODULE_NAME, + .description = "Print a separator line", + .parseCommandOptions = (void*) ffParseSeparatorCommandOptions, + .parseJsonObject = (void*) ffParseSeparatorJsonObject, + .printModule = (void*) ffPrintSeparator, + .generateJsonConfig = (void*) ffGenerateSeparatorJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Separator string", "string"}, + {"Output color", "outputColor"}, + {"Length", "length"}, + })) +}; + void ffInitSeparatorOptions(FFSeparatorOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_SEPARATOR_MODULE_NAME, - "Print a separator line", - ffParseSeparatorCommandOptions, - ffParseSeparatorJsonObject, - ffPrintSeparator, - NULL, - NULL, - ffGenerateSeparatorJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffStrbufInitStatic(&options->string, "-"); ffStrbufInit(&options->outputColor); options->length = 0; diff --git a/src/modules/shell/shell.c b/src/modules/shell/shell.c index 862997156..c29fa9d72 100644 --- a/src/modules/shell/shell.c +++ b/src/modules/shell/shell.c @@ -4,8 +4,6 @@ #include "modules/shell/shell.h" #include "util/stringUtils.h" -#define FF_SHELL_NUM_FORMAT_ARGS 8 - void ffPrintShell(FFShellOptions* options) { const FFShellResult* result = ffDetectShell(); @@ -31,7 +29,7 @@ void ffPrintShell(FFShellOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_SHELL_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(result->processName, "process-name"), FF_FORMAT_ARG(result->exe, "exe"), FF_FORMAT_ARG(result->exeName, "exe-name"), @@ -104,33 +102,29 @@ void ffGenerateShellJsonResult(FF_MAYBE_UNUSED FFShellOptions* options, yyjson_m yyjson_mut_obj_add_null(doc, obj, "tty"); } -void ffPrintShellHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_SHELL_MODULE_NAME, "{3} {4}", FF_SHELL_NUM_FORMAT_ARGS, ((const char* []) { - "Shell process name - process-name", - "The first argument of the command line when running the shell - exe", - "Shell base name of arg0 - exe-name", - "Shell version - version", - "Shell pid - pid", - "Shell pretty name - pretty-name", - "Shell full exe path - exe-path", - "Shell tty used - tty", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_SHELL_MODULE_NAME, + .description = "Print current shell name and version", + .parseCommandOptions = (void*) ffParseShellCommandOptions, + .parseJsonObject = (void*) ffParseShellJsonObject, + .printModule = (void*) ffPrintShell, + .generateJsonResult = (void*) ffGenerateShellJsonResult, + .generateJsonConfig = (void*) ffGenerateShellJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Shell process name", "process-name"}, + {"The first argument of the command line when running the shell", "exe"}, + {"Shell base name of arg0", "exe-name"}, + {"Shell version", "version"}, + {"Shell pid", "pid"}, + {"Shell pretty name", "pretty-name"}, + {"Shell full exe path", "exe-path"}, + {"Shell tty used", "tty"}, + })) +}; void ffInitShellOptions(FFShellOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_SHELL_MODULE_NAME, - "Print current shell name and version", - ffParseShellCommandOptions, - ffParseShellJsonObject, - ffPrintShell, - ffGenerateShellJsonResult, - ffPrintShellHelpFormat, - ffGenerateShellJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/sound/sound.c b/src/modules/sound/sound.c index 1e0cd7e84..756d47716 100644 --- a/src/modules/sound/sound.c +++ b/src/modules/sound/sound.c @@ -5,8 +5,6 @@ #include "modules/sound/sound.h" #include "util/stringUtils.h" -#define FF_SOUND_NUM_FORMAT_ARGS 5 - static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, uint8_t index) { FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type; @@ -54,7 +52,7 @@ static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, ui if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) ffPercentAppendBar(&percentageBar, device->volume, options->percent, &options->moduleArgs); - FF_PRINT_FORMAT_CHECKED(FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_SOUND_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(device->main, "is-main"), FF_FORMAT_ARG(device->name, "name"), FF_FORMAT_ARG(percentageNum, "volume-percentage"), @@ -229,30 +227,26 @@ void ffGenerateSoundJsonResult(FF_MAYBE_UNUSED FFSoundOptions* options, yyjson_m } } -void ffPrintSoundHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_SOUND_MODULE_NAME, "{2} ({3}%)", FF_SOUND_NUM_FORMAT_ARGS, ((const char* []) { - "Is main sound device - is-main", - "Device name - name", - "Volume (in percentage num) - volume-percentage", - "Identifier - identifier", - "Volume (in percentage bar) - volume-percentage-bar", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_SOUND_MODULE_NAME, + .description = "Print sound devices, volume, etc", + .parseCommandOptions = (void*) ffParseSoundCommandOptions, + .parseJsonObject = (void*) ffParseSoundJsonObject, + .printModule = (void*) ffPrintSound, + .generateJsonResult = (void*) ffGenerateSoundJsonResult, + .generateJsonConfig = (void*) ffGenerateSoundJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Is main sound device", "is-main"}, + {"Device name", "name"}, + {"Volume (in percentage num)", "volume-percentage"}, + {"Identifier", "identifier"}, + {"Volume (in percentage bar)", "volume-percentage-bar"}, + })) +}; void ffInitSoundOptions(FFSoundOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_SOUND_MODULE_NAME, - "Print sound devices, volume, etc", - ffParseSoundCommandOptions, - ffParseSoundJsonObject, - ffPrintSound, - ffGenerateSoundJsonResult, - ffPrintSoundHelpFormat, - ffGenerateSoundJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); options->soundType = FF_SOUND_TYPE_MAIN; diff --git a/src/modules/swap/swap.c b/src/modules/swap/swap.c index 6fba1f3aa..04995afa8 100644 --- a/src/modules/swap/swap.c +++ b/src/modules/swap/swap.c @@ -6,8 +6,6 @@ #include "modules/swap/swap.h" #include "util/stringUtils.h" -#define FF_SWAP_NUM_FORMAT_ARGS 4 - void ffPrintSwap(FFSwapOptions* options) { FFSwapResult storage = {}; @@ -73,7 +71,7 @@ void ffPrintSwap(FFSwapOptions* options) FF_STRBUF_AUTO_DESTROY percentageBar = ffStrbufCreate(); if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) ffPercentAppendBar(&percentageBar, percentage, options->percent, &options->moduleArgs); - FF_PRINT_FORMAT_CHECKED(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_SWAP_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(usedPretty, "used"), FF_FORMAT_ARG(totalPretty, "total"), FF_FORMAT_ARG(percentageNum, "percentage"), @@ -141,29 +139,25 @@ void ffGenerateSwapJsonResult(FF_MAYBE_UNUSED FFSwapOptions* options, yyjson_mut yyjson_mut_obj_add_uint(doc, obj, "used", storage.bytesUsed); } -void ffPrintSwapHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_SWAP_MODULE_NAME, "{1} / {2} ({3})", FF_SWAP_NUM_FORMAT_ARGS, ((const char* []) { - "Used size - used", - "Total size - total", - "Percentage used (num) - percentage", - "Percentage used (bar) - percentage-bar", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_SWAP_MODULE_NAME, + .description = "Print swap (paging file) space usage", + .parseCommandOptions = (void*) ffParseSwapCommandOptions, + .parseJsonObject = (void*) ffParseSwapJsonObject, + .printModule = (void*) ffPrintSwap, + .generateJsonResult = (void*) ffGenerateSwapJsonResult, + .generateJsonConfig = (void*) ffGenerateSwapJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Used size", "used"}, + {"Total size", "total"}, + {"Percentage used (num)", "percentage"}, + {"Percentage used (bar)", "percentage-bar"}, + })) +}; void ffInitSwapOptions(FFSwapOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_SWAP_MODULE_NAME, - "Print swap (paging file) space usage", - ffParseSwapCommandOptions, - ffParseSwapJsonObject, - ffPrintSwap, - ffGenerateSwapJsonResult, - ffPrintSwapHelpFormat, - ffGenerateSwapJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰓡"); options->percent = (FFPercentageModuleConfig) { 50, 80, 0 }; } diff --git a/src/modules/terminal/terminal.c b/src/modules/terminal/terminal.c index 85fd84af7..265cd7dbd 100644 --- a/src/modules/terminal/terminal.c +++ b/src/modules/terminal/terminal.c @@ -4,10 +4,6 @@ #include "modules/terminal/terminal.h" #include "util/stringUtils.h" -#include - -#define FF_TERMINAL_NUM_FORMAT_ARGS 8 - void ffPrintTerminal(FFTerminalOptions* options) { const FFTerminalResult* result = ffDetectTerminal(); @@ -29,7 +25,7 @@ void ffPrintTerminal(FFTerminalOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINAL_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(result->processName, "process-name"), FF_FORMAT_ARG(result->exe, "exe"), FF_FORMAT_ARG(result->exeName, "exe-name"), @@ -99,33 +95,29 @@ void ffGenerateTerminalJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options, yy yyjson_mut_obj_add_strbuf(doc, obj, "tty", &result->tty); } -void ffPrintTerminalHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TERMINAL_MODULE_NAME, "{5} {6}", FF_TERMINAL_NUM_FORMAT_ARGS, ((const char* []) { - "Terminal process name - process-name", - "The first argument of the command line when running the terminal - exe", - "Terminal base name of arg0 - exe-name", - "Terminal pid - pid", - "Terminal pretty name - pretty-name", - "Terminal version - version", - "Terminal full exe path - exe-path", - "Terminal tty / pts used - tty", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_TERMINAL_MODULE_NAME, + .description = "Print current terminal name and version", + .parseCommandOptions = (void*) ffParseTerminalCommandOptions, + .parseJsonObject = (void*) ffParseTerminalJsonObject, + .printModule = (void*) ffPrintTerminal, + .generateJsonResult = (void*) ffGenerateTerminalJsonResult, + .generateJsonConfig = (void*) ffGenerateTerminalJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Terminal process name", "process-name"}, + {"The first argument of the command line when running the terminal", "exe"}, + {"Terminal base name of arg0", "exe-name"}, + {"Terminal pid", "pid"}, + {"Terminal pretty name", "pretty-name"}, + {"Terminal version", "version"}, + {"Terminal full exe path", "exe-path"}, + {"Terminal tty / pts used", "tty"}, + })) +}; void ffInitTerminalOptions(FFTerminalOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_TERMINAL_MODULE_NAME, - "Print current terminal name and version", - ffParseTerminalCommandOptions, - ffParseTerminalJsonObject, - ffPrintTerminal, - ffGenerateTerminalJsonResult, - ffPrintTerminalHelpFormat, - ffGenerateTerminalJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/terminalfont/terminalfont.c b/src/modules/terminalfont/terminalfont.c index a686babe5..a8376f586 100644 --- a/src/modules/terminalfont/terminalfont.c +++ b/src/modules/terminalfont/terminalfont.c @@ -5,7 +5,6 @@ #include "util/stringUtils.h" #define FF_TERMINALFONT_DISPLAY_NAME "Terminal Font" -#define FF_TERMINALFONT_NUM_FORMAT_ARGS 4 void ffPrintTerminalFont(FFTerminalFontOptions* options) { @@ -33,7 +32,7 @@ void ffPrintTerminalFont(FFTerminalFontOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINALFONT_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(terminalFont.font.pretty, "combined"), FF_FORMAT_ARG(terminalFont.font.name, "name"), FF_FORMAT_ARG(terminalFont.font.size, "size"), @@ -121,29 +120,25 @@ void ffGenerateTerminalFontJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options ffFontDestroy(&result.fallback); } -void ffPrintTerminalFontHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TERMINALFONT_MODULE_NAME, "{1}", FF_TERMINALFONT_NUM_FORMAT_ARGS, ((const char* []) { - "Terminal font combined - combined", - "Terminal font name - name", - "Terminal font size - size", - "Terminal font styles - styles", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_TERMINALFONT_MODULE_NAME, + .description = "Print font name and size used by current terminal", + .parseCommandOptions = (void*) ffParseTerminalFontCommandOptions, + .parseJsonObject = (void*) ffParseTerminalFontJsonObject, + .printModule = (void*) ffPrintTerminalFont, + .generateJsonResult = (void*) ffGenerateTerminalFontJsonResult, + .generateJsonConfig = (void*) ffGenerateTerminalFontJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Terminal font combined", "combined"}, + {"Terminal font name", "name"}, + {"Terminal font size", "size"}, + {"Terminal font styles", "styles"}, + })), +}; void ffInitTerminalFontOptions(FFTerminalFontOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_TERMINALFONT_MODULE_NAME, - "Print font name and size used by current terminal", - ffParseTerminalFontCommandOptions, - ffParseTerminalFontJsonObject, - ffPrintTerminalFont, - ffGenerateTerminalFontJsonResult, - ffPrintTerminalFontHelpFormat, - ffGenerateTerminalFontJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/terminalsize/terminalsize.c b/src/modules/terminalsize/terminalsize.c index 71272281e..4639aefc7 100644 --- a/src/modules/terminalsize/terminalsize.c +++ b/src/modules/terminalsize/terminalsize.c @@ -5,7 +5,6 @@ #include "util/stringUtils.h" #define FF_TERMINALSIZE_DISPLAY_NAME "Terminal Size" -#define FF_TERMINALSIZE_NUM_FORMAT_ARGS 4 void ffPrintTerminalSize(FFTerminalSizeOptions* options) { @@ -29,7 +28,7 @@ void ffPrintTerminalSize(FFTerminalSizeOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINALSIZE_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(result.rows, "rows"), FF_FORMAT_ARG(result.columns, "columns"), FF_FORMAT_ARG(result.width, "width"), @@ -91,29 +90,25 @@ void ffGenerateTerminalSizeJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options yyjson_mut_obj_add_uint(doc, obj, "height", result.height); } -void ffPrintTerminalSizeHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TERMINALSIZE_MODULE_NAME, "{1} columns x {2} rows ({3}px x {4}px)", FF_TERMINALSIZE_NUM_FORMAT_ARGS, ((const char* []) { - "Terminal rows - rows", - "Terminal columns - columns", - "Terminal width (in pixels) - width", - "Terminal height (in pixels) - height", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_TERMINALSIZE_MODULE_NAME, + .description = "Print current terminal size", + .parseCommandOptions = (void*) ffParseTerminalSizeCommandOptions, + .parseJsonObject = (void*) ffParseTerminalSizeJsonObject, + .printModule = (void*) ffPrintTerminalSize, + .generateJsonResult = (void*) ffGenerateTerminalSizeJsonResult, + .generateJsonConfig = (void*) ffGenerateTerminalSizeJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Terminal rows", "rows"}, + {"Terminal columns", "columns"}, + {"Terminal width (in pixels)", "width"}, + {"Terminal height (in pixels)", "height"}, + })), +}; void ffInitTerminalSizeOptions(FFTerminalSizeOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_TERMINALSIZE_MODULE_NAME, - "Print current terminal size", - ffParseTerminalSizeCommandOptions, - ffParseTerminalSizeJsonObject, - ffPrintTerminalSize, - ffGenerateTerminalSizeJsonResult, - ffPrintTerminalSizeHelpFormat, - ffGenerateTerminalSizeJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰲎"); } diff --git a/src/modules/terminaltheme/terminaltheme.c b/src/modules/terminaltheme/terminaltheme.c index 5ff7e720e..a81971d11 100644 --- a/src/modules/terminaltheme/terminaltheme.c +++ b/src/modules/terminaltheme/terminaltheme.c @@ -7,7 +7,6 @@ #include #define FF_TERMINALTHEME_DISPLAY_NAME "Terminal Theme" -#define FF_TERMINALTHEME_NUM_FORMAT_ARGS 4 void ffPrintTerminalTheme(FFTerminalThemeOptions* options) { @@ -34,7 +33,7 @@ void ffPrintTerminalTheme(FFTerminalThemeOptions* options) const char* bgType = result.bg.dark ? "Dark" : "Light"; snprintf(fg, ARRAY_SIZE(fg), "#%02" PRIX16 "%02" PRIX16 "%02" PRIX16, result.fg.r, result.fg.g, result.fg.b); snprintf(bg, ARRAY_SIZE(bg), "#%02" PRIX16 "%02" PRIX16 "%02" PRIX16, result.bg.r, result.bg.g, result.bg.b); - FF_PRINT_FORMAT_CHECKED(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINALTHEME_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(fg, "fg-color"), FF_FORMAT_ARG(fgType, "fg-type"), FF_FORMAT_ARG(bg, "bg-color"), @@ -104,29 +103,25 @@ void ffGenerateTerminalThemeJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* option yyjson_mut_obj_add_bool(doc, bg, "dark", result.bg.dark); } -void ffPrintTerminalThemeHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TERMINALTHEME_MODULE_NAME, "{1} (FG) {3} (BG) [{4}]", FF_TERMINALTHEME_NUM_FORMAT_ARGS, ((const char* []) { - "Terminal foreground color - fg-color", - "Terminal foreground type (Dark / Light) - fg-type", - "Terminal background color - bg-color", - "Terminal background type (Dark / Light) - bg-type", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_TERMINALTHEME_MODULE_NAME, + .description = "Print current terminal theme (foreground and background colors)", + .parseCommandOptions = (void*) ffParseTerminalThemeCommandOptions, + .parseJsonObject = (void*) ffParseTerminalThemeJsonObject, + .printModule = (void*) ffPrintTerminalTheme, + .generateJsonResult = (void*) ffGenerateTerminalThemeJsonResult, + .generateJsonConfig = (void*) ffGenerateTerminalThemeJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Terminal foreground color", "fg-color"}, + {"Terminal foreground type (Dark / Light)", "fg-type"}, + {"Terminal background color", "bg-color"}, + {"Terminal background type (Dark / Light)", "bg-type"}, + })) +}; void ffInitTerminalThemeOptions(FFTerminalThemeOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_TERMINALTHEME_MODULE_NAME, - "Print current terminal theme (foreground and background colors)", - ffParseTerminalThemeCommandOptions, - ffParseTerminalThemeJsonObject, - ffPrintTerminalTheme, - ffGenerateTerminalThemeJsonResult, - ffPrintTerminalThemeHelpFormat, - ffGenerateTerminalThemeJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰔎"); } diff --git a/src/modules/theme/theme.c b/src/modules/theme/theme.c index bef3c2594..7c4901753 100644 --- a/src/modules/theme/theme.c +++ b/src/modules/theme/theme.c @@ -4,8 +4,6 @@ #include "modules/theme/theme.h" #include "util/stringUtils.h" -#define FF_THEME_NUM_FORMAT_ARGS 2 - void ffPrintTheme(FFThemeOptions* options) { FFThemeResult result = { @@ -35,7 +33,7 @@ void ffPrintTheme(FFThemeOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_THEME_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(result.theme1, "theme1"), FF_FORMAT_ARG(result.theme2, "theme2"), })); @@ -102,27 +100,23 @@ void ffGenerateThemeJsonResult(FF_MAYBE_UNUSED FFThemeOptions* options, yyjson_m ffStrbufDestroy(&result.theme2); } -void ffPrintThemeHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_THEME_MODULE_NAME, "{1}, {2}", FF_THEME_NUM_FORMAT_ARGS, ((const char* []) { - "Theme part 1 - theme1", - "Theme part 2 - theme2", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_THEME_MODULE_NAME, + .description = "Print current theme of desktop environment", + .parseCommandOptions = (void*) ffParseThemeCommandOptions, + .parseJsonObject = (void*) ffParseThemeJsonObject, + .printModule = (void*) ffPrintTheme, + .generateJsonResult = (void*) ffGenerateThemeJsonResult, + .generateJsonConfig = (void*) ffGenerateThemeJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Theme part 1", "theme1"}, + {"Theme part 2", "theme2"}, + })) +}; void ffInitThemeOptions(FFThemeOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_THEME_MODULE_NAME, - "Print current theme of desktop environment", - ffParseThemeCommandOptions, - ffParseThemeJsonObject, - ffPrintTheme, - ffGenerateThemeJsonResult, - ffPrintThemeHelpFormat, - ffGenerateThemeJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰉼"); } diff --git a/src/modules/title/title.c b/src/modules/title/title.c index bd363ce5a..31b5e79c4 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -4,8 +4,6 @@ #include "util/textModifier.h" #include "util/stringUtils.h" -#define FF_TITLE_NUM_FORMAT_ARGS 8 - static void appendText(FFstrbuf* output, const FFstrbuf* text, const FFstrbuf* color) { if (!instance.config.display.pipe) @@ -56,7 +54,7 @@ void ffPrintTitle(FFTitleOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_TITLE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TITLE_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_TITLE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(instance.state.platform.userName, "user-name"), FF_FORMAT_ARG(hostName, "host-name"), FF_FORMAT_ARG(instance.state.platform.homeDir, "home-dir"), @@ -178,33 +176,29 @@ void ffGenerateTitleJsonResult(FF_MAYBE_UNUSED FFTitleOptions* options, yyjson_m yyjson_mut_obj_add_strbuf(doc, obj, "userShell", &instance.state.platform.userShell); } -void ffPrintTitleHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TITLE_MODULE_NAME, "{6}{7}{8}", FF_TITLE_NUM_FORMAT_ARGS, ((const char* []) { - "User name - user-name", - "Host name - host-name", - "Home directory - home-dir", - "Executable path of current process - exe-path", - "User's default shell - user-shell", - "User name (colored) - user-name-colored", - "@ symbol (colored) - at-symbol-colored", - "Host name (colored) - host-name-colored", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_TITLE_MODULE_NAME, + .description = "Print title, which contains your user name, hostname", + .parseCommandOptions = (void*) ffParseTitleCommandOptions, + .parseJsonObject = (void*) ffParseTitleJsonObject, + .printModule = (void*) ffPrintTitle, + .generateJsonResult = (void*) ffGenerateTitleJsonResult, + .generateJsonConfig = (void*) ffGenerateTitleJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"User name", "user-name"}, + {"Host name", "host-name"}, + {"Home directory", "home-dir"}, + {"Executable path of current process", "exe-path"}, + {"User's default shell", "user-shell"}, + {"User name (colored)", "user-name-colored"}, + {"@ symbol (colored)", "at-symbol-colored"}, + {"Host name (colored)", "host-name-colored"}, + })) +}; void ffInitTitleOptions(FFTitleOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_TITLE_MODULE_NAME, - "Print title, which contains your user name, hostname", - ffParseTitleCommandOptions, - ffParseTitleJsonObject, - ffPrintTitle, - ffGenerateTitleJsonResult, - ffPrintTitleHelpFormat, - ffGenerateTitleJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); ffStrbufSetStatic(&options->moduleArgs.key, " "); diff --git a/src/modules/tpm/tpm.c b/src/modules/tpm/tpm.c index 3934fb4ce..8cbbd840d 100644 --- a/src/modules/tpm/tpm.c +++ b/src/modules/tpm/tpm.c @@ -4,8 +4,6 @@ #include "modules/tpm/tpm.h" #include "util/stringUtils.h" -#define FF_TPM_NUM_FORMAT_ARGS 2 - void ffPrintTPM(FFTPMOptions* options) { FFTPMResult result = { @@ -30,7 +28,7 @@ void ffPrintTPM(FFTPMOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_TPM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TPM_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_TPM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(result.version, "version"), FF_FORMAT_ARG(result.description, "description"), })); @@ -97,27 +95,23 @@ void ffGenerateTPMJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options, yyjson_ ffStrbufDestroy(&result.description); } -void ffPrintTPMHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TPM_MODULE_NAME, "{2}", FF_TPM_NUM_FORMAT_ARGS, ((const char* []) { - "TPM device version - version", - "TPM general description - description", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_TPM_MODULE_NAME, + .description = "Print info of Trusted Platform Module (TPM) Security Device", + .parseCommandOptions = (void*) ffParseTPMCommandOptions, + .parseJsonObject = (void*) ffParseTPMJsonObject, + .printModule = (void*) ffPrintTPM, + .generateJsonResult = (void*) ffGenerateTPMJsonResult, + .generateJsonConfig = (void*) ffGenerateTPMJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"TPM device version", "version"}, + {"TPM general description", "description"}, + })) +}; void ffInitTPMOptions(FFTPMOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_TPM_MODULE_NAME, - "Print info of Trusted Platform Module (TPM) Security Device", - ffParseTPMCommandOptions, - ffParseTPMJsonObject, - ffPrintTPM, - ffGenerateTPMJsonResult, - ffPrintTPMHelpFormat, - ffGenerateTPMJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/uptime/uptime.c b/src/modules/uptime/uptime.c index 935957df1..d76db17bf 100644 --- a/src/modules/uptime/uptime.c +++ b/src/modules/uptime/uptime.c @@ -5,8 +5,6 @@ #include "modules/uptime/uptime.h" #include "util/stringUtils.h" -#define FF_UPTIME_NUM_FORMAT_ARGS 6 - void ffPrintUptime(FFUptimeOptions* options) { FFUptimeResult result; @@ -41,7 +39,7 @@ void ffPrintUptime(FFUptimeOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_UPTIME_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(days, "days"), FF_FORMAT_ARG(hours, "hours"), FF_FORMAT_ARG(minutes, "minutes"), @@ -103,31 +101,27 @@ void ffGenerateUptimeJsonResult(FF_MAYBE_UNUSED FFUptimeOptions* options, yyjson yyjson_mut_obj_add_strcpy(doc, obj, "bootTime", ffTimeToFullStr(result.bootTime)); } -void ffPrintUptimeHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_UPTIME_MODULE_NAME, "{1} days {2} hours {3} mins", FF_UPTIME_NUM_FORMAT_ARGS, ((const char* []) { - "Days - days", - "Hours - hours", - "Minutes - minutes", - "Seconds - seconds", - "Milliseconds - milliseconds", - "Boot time in local timezone - boot-time", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_UPTIME_MODULE_NAME, + .description = "Print how long system has been running", + .parseCommandOptions = (void*) ffParseUptimeCommandOptions, + .parseJsonObject = (void*) ffParseUptimeJsonObject, + .printModule = (void*) ffPrintUptime, + .generateJsonResult = (void*) ffGenerateUptimeJsonResult, + .generateJsonConfig = (void*) ffGenerateUptimeJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Days", "days"}, + {"Hours", "hours"}, + {"Minutes", "minutes"}, + {"Seconds", "seconds"}, + {"Milliseconds", "milliseconds"}, + {"Boot time in local timezone", "boot-time"}, + })) +}; void ffInitUptimeOptions(FFUptimeOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_UPTIME_MODULE_NAME, - "Print how long system has been running", - ffParseUptimeCommandOptions, - ffParseUptimeJsonObject, - ffPrintUptime, - ffGenerateUptimeJsonResult, - ffPrintUptimeHelpFormat, - ffGenerateUptimeJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/users/users.c b/src/modules/users/users.c index 650db448d..cf9bd5dc2 100644 --- a/src/modules/users/users.c +++ b/src/modules/users/users.c @@ -7,8 +7,6 @@ #pragma GCC diagnostic ignored "-Wformat" // warning: unknown conversion type character 'F' in format -#define FF_USERS_NUM_FORMAT_ARGS 5 - void ffPrintUsers(FFUsersOptions* options) { FF_LIST_AUTO_DESTROY users = ffListCreate(sizeof(FFUserResult)); @@ -68,7 +66,7 @@ void ffPrintUsers(FFUsersOptions* options) { FFUserResult* user = FF_LIST_GET(FFUserResult, users, i); - FF_PRINT_FORMAT_CHECKED(FF_USERS_MODULE_NAME, users.length == 1 ? 0 : (uint8_t) (i + 1), &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_USERS_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_USERS_MODULE_NAME, users.length == 1 ? 0 : (uint8_t) (i + 1), &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(user->name, "name"), FF_FORMAT_ARG(user->hostName, "host-name"), FF_FORMAT_ARG(user->sessionName, "session-name"), @@ -188,30 +186,26 @@ void ffGenerateUsersJsonResult(FFUsersOptions* options, yyjson_mut_doc* doc, yyj } } -void ffPrintUsersHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_USERS_MODULE_NAME, "{1}@{2} - login time {5}", FF_USERS_NUM_FORMAT_ARGS, ((const char* []) { - "User name - name", - "Host name - host-name", - "Session name - session", - "Client IP - client-ip", - "Login Time in local timezone - login-time", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_USERS_MODULE_NAME, + .description = "Print users currently logged in", + .parseCommandOptions = (void*) ffParseUsersCommandOptions, + .parseJsonObject = (void*) ffParseUsersJsonObject, + .printModule = (void*) ffPrintUsers, + .generateJsonResult = (void*) ffGenerateUsersJsonResult, + .generateJsonConfig = (void*) ffGenerateUsersJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"User name", "name"}, + {"Host name", "host-name"}, + {"Session name", "session"}, + {"Client IP", "client-ip"}, + {"Login Time in local timezone", "login-time"}, + })) +}; void ffInitUsersOptions(FFUsersOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_USERS_MODULE_NAME, - "Print users currently logged in", - ffParseUsersCommandOptions, - ffParseUsersJsonObject, - ffPrintUsers, - ffGenerateUsersJsonResult, - ffPrintUsersHelpFormat, - ffGenerateUsersJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); options->compact = false; diff --git a/src/modules/version/version.c b/src/modules/version/version.c index 73b5e7dde..d49a26065 100644 --- a/src/modules/version/version.c +++ b/src/modules/version/version.c @@ -5,8 +5,6 @@ #include "modules/version/version.h" #include "util/stringUtils.h" -#define FF_VERSION_NUM_FORMAT_ARGS 10 - void ffPrintVersion(FFVersionOptions* options) { FFVersionResult* result = &ffVersionResult; @@ -31,7 +29,7 @@ void ffPrintVersion(FFVersionOptions* options) } const char* buildType = result->debugMode ? "debug" : "release"; - FF_PRINT_FORMAT_CHECKED(FF_VERSION_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_VERSION_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_VERSION_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(result->projectName, "project-name"), FF_FORMAT_ARG(result->version, "version"), FF_FORMAT_ARG(result->versionTweak, "version-tweak"), @@ -41,7 +39,7 @@ void ffPrintVersion(FFVersionOptions* options) FF_FORMAT_ARG(result->cmakeBuiltType, "cmake-built-type"), FF_FORMAT_ARG(result->compileTime, "compile-time"), FF_FORMAT_ARG(result->compiler, "compiler"), - FF_FORMAT_ARG(buf, "libc-used"), + FF_FORMAT_ARG(buf, "libc"), })); } } @@ -113,35 +111,31 @@ void ffGenerateVersionJsonResult(FF_MAYBE_UNUSED FFVersionOptions* options, yyjs } } -void ffPrintVersionHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_VERSION_MODULE_NAME, "{1} {2}{3} ({5})", FF_VERSION_NUM_FORMAT_ARGS, ((const char* []) { - "Project name - name", - "Version - version", - "Version tweak - version-tweak", - "Build type (debug or release) - build-type", - "System name - sysname", - "Architecture - arch", - "CMake build type when compiling (Debug, Release, RelWithDebInfo, MinSizeRel) - cmake-built-type", - "Date time when compiling - compile-time", - "Compiler used when compiling - compiler", - "Libc used when compiling - libc", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_VERSION_MODULE_NAME, + .description = "Print Fastfetch version", + .parseCommandOptions = (void*) ffParseVersionCommandOptions, + .parseJsonObject = (void*) ffParseVersionJsonObject, + .printModule = (void*) ffPrintVersion, + .generateJsonResult = (void*) ffGenerateVersionJsonResult, + .generateJsonConfig = (void*) ffGenerateVersionJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Project name", "name"}, + {"Version", "version"}, + {"Version tweak", "version-tweak"}, + {"Build type (debug or release)", "build-type"}, + {"System name", "sysname"}, + {"Architecture", "arch"}, + {"CMake build type when compiling (Debug, Release, RelWithDebInfo, MinSizeRel)", "cmake-built-type"}, + {"Date time when compiling", "compile-time"}, + {"Compiler used when compiling", "compiler"}, + {"Libc used when compiling", "libc"}, + })) +}; void ffInitVersionOptions(FFVersionOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_VERSION_MODULE_NAME, - "Print Fastfetch version", - ffParseVersionCommandOptions, - ffParseVersionJsonObject, - ffPrintVersion, - ffGenerateVersionJsonResult, - ffPrintVersionHelpFormat, - ffGenerateVersionJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/vulkan/vulkan.c b/src/modules/vulkan/vulkan.c index dbafd7ef8..a08f4b9ba 100644 --- a/src/modules/vulkan/vulkan.c +++ b/src/modules/vulkan/vulkan.c @@ -5,8 +5,6 @@ #include "modules/vulkan/vulkan.h" #include "util/stringUtils.h" -#define FF_VULKAN_NUM_FORMAT_ARGS 4 - void ffPrintVulkan(FFVulkanOptions* options) { const FFVulkanResult* vulkan = ffDetectVulkan(); @@ -43,7 +41,7 @@ void ffPrintVulkan(FFVulkanOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_VULKAN_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(vulkan->driver, "driver"), FF_FORMAT_ARG(vulkan->apiVersion, "api-version"), FF_FORMAT_ARG(vulkan->conformanceVersion, "conformance-version"), @@ -144,29 +142,25 @@ void ffGenerateVulkanJsonResult(FF_MAYBE_UNUSED FFVulkanOptions* options, yyjson } } -void ffPrintVulkanHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_VULKAN_MODULE_NAME, "{2} - {1}", FF_VULKAN_NUM_FORMAT_ARGS, ((const char* []) { - "Driver name - driver", - "API version - api-version", - "Conformance version - conformance-version", - "Instance version - instance-version", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_VULKAN_MODULE_NAME, + .description = "Print highest Vulkan version supported by the GPU", + .parseCommandOptions = (void*) ffParseVulkanCommandOptions, + .parseJsonObject = (void*) ffParseVulkanJsonObject, + .printModule = (void*) ffPrintVulkan, + .generateJsonResult = (void*) ffGenerateVulkanJsonResult, + .generateJsonConfig = (void*) ffGenerateVulkanJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Driver name", "driver"}, + {"API version", "api-version"}, + {"Conformance version", "conformance-version"}, + {"Instance version", "instance-version"}, + })) +}; void ffInitVulkanOptions(FFVulkanOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_VULKAN_MODULE_NAME, - "Print highest Vulkan version supported by the GPU", - ffParseVulkanCommandOptions, - ffParseVulkanJsonObject, - ffPrintVulkan, - ffGenerateVulkanJsonResult, - ffPrintVulkanHelpFormat, - ffGenerateVulkanJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); } diff --git a/src/modules/wallpaper/wallpaper.c b/src/modules/wallpaper/wallpaper.c index 901cdd12e..7e5b46af0 100644 --- a/src/modules/wallpaper/wallpaper.c +++ b/src/modules/wallpaper/wallpaper.c @@ -4,8 +4,6 @@ #include "modules/wallpaper/wallpaper.h" #include "util/stringUtils.h" -#define FF_WALLPAPER_NUM_FORMAT_ARGS 2 - void ffPrintWallpaper(FFWallpaperOptions* options) { FF_STRBUF_AUTO_DESTROY fullpath = ffStrbufCreate(); @@ -35,7 +33,7 @@ void ffPrintWallpaper(FFWallpaperOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_WALLPAPER_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(filename, "file-name"), FF_FORMAT_ARG(fullpath, "full-path"), })); @@ -89,27 +87,23 @@ void ffGenerateWallpaperJsonResult(FF_MAYBE_UNUSED FFWallpaperOptions* options, yyjson_mut_obj_add_strbuf(doc, module, "result", &fullpath); } -void ffPrintWallpaperHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_WALLPAPER_MODULE_NAME, "{1}", FF_WALLPAPER_NUM_FORMAT_ARGS, ((const char* []) { - "File name - file-name", - "Full path - full-path", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_WALLPAPER_MODULE_NAME, + .description = "Print image file path of current wallpaper", + .parseCommandOptions = (void*) ffParseWallpaperCommandOptions, + .parseJsonObject = (void*) ffParseWallpaperJsonObject, + .printModule = (void*) ffPrintWallpaper, + .generateJsonResult = (void*) ffGenerateWallpaperJsonResult, + .generateJsonConfig = (void*) ffGenerateWallpaperJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"File name", "file-name"}, + {"Full path", "full-path"}, + })) +}; void ffInitWallpaperOptions(FFWallpaperOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_WALLPAPER_MODULE_NAME, - "Print image file path of current wallpaper", - ffParseWallpaperCommandOptions, - ffParseWallpaperJsonObject, - ffPrintWallpaper, - ffGenerateWallpaperJsonResult, - ffPrintWallpaperHelpFormat, - ffGenerateWallpaperJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰸉"); } diff --git a/src/modules/weather/weather.c b/src/modules/weather/weather.c index c46ea3899..f63a026e7 100644 --- a/src/modules/weather/weather.c +++ b/src/modules/weather/weather.c @@ -4,8 +4,6 @@ #include "modules/weather/weather.h" #include "util/stringUtils.h" -#define FF_WEATHER_NUM_FORMAT_ARGS 1 - void ffPrintWeather(FFWeatherOptions* options) { FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate(); @@ -25,7 +23,7 @@ void ffPrintWeather(FFWeatherOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_WEATHER_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(result, "result"), })); } @@ -125,26 +123,22 @@ void ffGenerateWeatherJsonResult(FFWeatherOptions* options, yyjson_mut_doc* doc, yyjson_mut_obj_add_strbuf(doc, module, "result", &result); } -void ffPrintWeatherHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_WEATHER_MODULE_NAME, "{1}", FF_WEATHER_NUM_FORMAT_ARGS, ((const char* []) { - "Weather result - result", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_WEATHER_MODULE_NAME, + .description = "Print weather information", + .parseCommandOptions = (void*) ffParseWeatherCommandOptions, + .parseJsonObject = (void*) ffParseWeatherJsonObject, + .printModule = (void*) ffPrintWeather, + .generateJsonResult = (void*) ffGenerateWeatherJsonResult, + .generateJsonConfig = (void*) ffGenerateWeatherJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Weather result", "result"}, + })) +}; void ffInitWeatherOptions(FFWeatherOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_WEATHER_MODULE_NAME, - "Print weather information", - ffParseWeatherCommandOptions, - ffParseWeatherJsonObject, - ffPrintWeather, - ffGenerateWeatherJsonResult, - ffPrintWeatherHelpFormat, - ffGenerateWeatherJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰖙"); ffStrbufInit(&options->location); diff --git a/src/modules/wifi/wifi.c b/src/modules/wifi/wifi.c index f52382d0c..7bb5f7994 100644 --- a/src/modules/wifi/wifi.c +++ b/src/modules/wifi/wifi.c @@ -4,8 +4,6 @@ #include "modules/wifi/wifi.h" #include "util/stringUtils.h" -#define FF_WIFI_NUM_FORMAT_ARGS 13 - void ffPrintWifi(FFWifiOptions* options) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFWifiResult)); @@ -108,7 +106,7 @@ void ffPrintWifi(FFWifiOptions* options) if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) ffPercentAppendBar(&percentBar, item->conn.signalQuality, options->percent, &options->moduleArgs); - FF_PRINT_FORMAT_CHECKED(FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_WIFI_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(item->inf.description, "inf-desc"), FF_FORMAT_ARG(item->inf.status, "inf-status"), FF_FORMAT_ARG(item->conn.status, "status"), @@ -222,38 +220,34 @@ void ffGenerateWifiJsonResult(FF_MAYBE_UNUSED FFWifiOptions* options, yyjson_mut } } -void ffPrintWifiHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_WIFI_MODULE_NAME, "{4} - {10}", FF_WIFI_NUM_FORMAT_ARGS, ((const char* []) { - "Interface description - inf-desc", - "Interface status - inf-status", - "Connection status - status", - "Connection SSID - ssid", - "Connection BSSID - bssid", - "Connection protocol - protocol", - "Connection signal quality (percentage num) - signal-quality", - "Connection RX rate - rx-rate", - "Connection TX rate - tx-rate", - "Connection Security algorithm - security", - "Connection signal quality (percentage bar) - signal-quality-bar", - "Connection channel number - channel", - "Connection channel band in GHz - band", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_WIFI_MODULE_NAME, + .description = "Print connected Wi-Fi info (SSID, connection and security protocol)", + .parseCommandOptions = (void*) ffParseWifiCommandOptions, + .parseJsonObject = (void*) ffParseWifiJsonObject, + .printModule = (void*) ffPrintWifi, + .generateJsonResult = (void*) ffGenerateWifiJsonResult, + .generateJsonConfig = (void*) ffGenerateWifiJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Interface description", "inf-desc"}, + {"Interface status", "inf-status"}, + {"Connection status", "status"}, + {"Connection SSID", "ssid"}, + {"Connection BSSID", "bssid"}, + {"Connection protocol", "protocol"}, + {"Connection signal quality (percentage num)", "signal-quality"}, + {"Connection RX rate", "rx-rate"}, + {"Connection TX rate", "tx-rate"}, + {"Connection Security algorithm", "security"}, + {"Connection signal quality (percentage bar)", "signal-quality-bar"}, + {"Connection channel number", "channel"}, + {"Connection channel band in GHz", "band"}, + })) +}; void ffInitWifiOptions(FFWifiOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_WIFI_MODULE_NAME, - "Print connected Wi-Fi info (SSID, connection and security protocol)", - ffParseWifiCommandOptions, - ffParseWifiJsonObject, - ffPrintWifi, - ffGenerateWifiJsonResult, - ffPrintWifiHelpFormat, - ffGenerateWifiJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); options->percent = (FFPercentageModuleConfig) { 50, 20, 0 }; diff --git a/src/modules/wm/wm.c b/src/modules/wm/wm.c index 97dba1941..dc02ba4c0 100644 --- a/src/modules/wm/wm.c +++ b/src/modules/wm/wm.c @@ -5,8 +5,6 @@ #include "modules/wm/wm.h" #include "util/stringUtils.h" -#define FF_WM_NUM_FORMAT_ARGS 4 - void ffPrintWM(FFWMOptions* options) { const FFDisplayServerResult* result = ffConnectDisplayServer(); @@ -45,7 +43,7 @@ void ffPrintWM(FFWMOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_WM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_WM_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_WM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(result->wmProcessName, "process-name"), FF_FORMAT_ARG(result->wmPrettyName, "pretty-name"), FF_FORMAT_ARG(result->wmProtocolName, "protocol-name"), @@ -125,29 +123,25 @@ void ffGenerateWMJsonResult(FF_MAYBE_UNUSED FFWMOptions* options, yyjson_mut_doc yyjson_mut_obj_add_strbuf(doc, obj, "pluginName", &pluginName); } -void ffPrintWMHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_WM_MODULE_NAME, "{2} ({3})", FF_WM_NUM_FORMAT_ARGS, ((const char* []) { - "WM process name - process-name", - "WM pretty name - pretty-name", - "WM protocol name - protocol-name", - "WM plugin name - plugin-name", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_WM_MODULE_NAME, + .description = "Print window manager name and version", + .parseCommandOptions = (void*) ffParseWMCommandOptions, + .parseJsonObject = (void*) ffParseWMJsonObject, + .printModule = (void*) ffPrintWM, + .generateJsonResult = (void*) ffGenerateWMJsonResult, + .generateJsonConfig = (void*) ffGenerateWMJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"WM process name", "process-name"}, + {"WM pretty name", "pretty-name"}, + {"WM protocol name", "protocol-name"}, + {"WM plugin name", "plugin-name"}, + })) +}; void ffInitWMOptions(FFWMOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_WM_MODULE_NAME, - "Print window manager name and version", - ffParseWMCommandOptions, - ffParseWMJsonObject, - ffPrintWM, - ffGenerateWMJsonResult, - ffPrintWMHelpFormat, - ffGenerateWMJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, ""); options->detectPlugin = false; } diff --git a/src/modules/wmtheme/wmtheme.c b/src/modules/wmtheme/wmtheme.c index 6f81c89ad..bfddcfbba 100644 --- a/src/modules/wmtheme/wmtheme.c +++ b/src/modules/wmtheme/wmtheme.c @@ -5,7 +5,6 @@ #include "util/stringUtils.h" #define FF_WMTHEME_DISPLAY_NAME "WM Theme" -#define FF_WMTHEME_NUM_FORMAT_ARGS 1 void ffPrintWMTheme(FFWMThemeOptions* options) { @@ -19,7 +18,7 @@ void ffPrintWMTheme(FFWMThemeOptions* options) } else { - FF_PRINT_FORMAT_CHECKED(FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_WMTHEME_NUM_FORMAT_ARGS, ((FFformatarg[]){ + FF_PRINT_FORMAT_CHECKED(FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(themeOrError, "result"), })); } @@ -77,26 +76,22 @@ void ffGenerateWMThemeJsonResult(FF_MAYBE_UNUSED FFWMThemeOptions* options, yyjs yyjson_mut_obj_add_strbuf(doc, module, "result", &themeOrError); } -void ffPrintWMthemeHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_WMTHEME_MODULE_NAME, "{1}", FF_WMTHEME_NUM_FORMAT_ARGS, ((const char* []) { - "WM theme - result", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_WMTHEME_MODULE_NAME, + .description = "Print current theme of window manager", + .parseCommandOptions = (void*) ffParseWMThemeCommandOptions, + .parseJsonObject = (void*) ffParseWMThemeJsonObject, + .printModule = (void*) ffPrintWMTheme, + .generateJsonResult = (void*) ffGenerateWMThemeJsonResult, + .generateJsonConfig = (void*) ffGenerateWMThemeJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"WM theme", "result"}, + })) +}; void ffInitWMThemeOptions(FFWMThemeOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_WMTHEME_MODULE_NAME, - "Print current theme of window manager", - ffParseWMThemeCommandOptions, - ffParseWMThemeJsonObject, - ffPrintWMTheme, - ffGenerateWMThemeJsonResult, - ffPrintWMthemeHelpFormat, - ffGenerateWMThemeJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󰓸"); } diff --git a/src/modules/zpool/zpool.c b/src/modules/zpool/zpool.c index a47cb244d..5ee356e08 100644 --- a/src/modules/zpool/zpool.c +++ b/src/modules/zpool/zpool.c @@ -5,8 +5,6 @@ #include "modules/zpool/zpool.h" #include "util/stringUtils.h" -#define FF_ZPOOL_NUM_FORMAT_ARGS 8 - static void printZpool(FFZpoolOptions* options, FFZpoolResult* result, uint8_t index) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); @@ -20,7 +18,7 @@ static void printZpool(FFZpoolOptions* options, FFZpoolResult* result, uint8_t i else { ffStrbufClear(&buffer); - FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, 3, ((FFformatarg[]){ + FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, ((FFformatarg[]) { FF_FORMAT_ARG(index, "index"), FF_FORMAT_ARG(result->name, "name"), FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), @@ -64,7 +62,7 @@ static void printZpool(FFZpoolOptions* options, FFZpoolResult* result, uint8_t i if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) ffPercentAppendBar(&fragPercentageBar, result->fragmentation, options->percent, &options->moduleArgs); - FF_PRINT_FORMAT_CHECKED(buffer.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_ZPOOL_NUM_FORMAT_ARGS, ((FFformatarg[]) { + FF_PRINT_FORMAT_CHECKED(buffer.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) { FF_FORMAT_ARG(result->name, "name"), FF_FORMAT_ARG(result->state, "state"), FF_FORMAT_ARG(usedPretty, "size-used"), @@ -182,33 +180,29 @@ void ffGenerateZpoolJsonResult(FF_MAYBE_UNUSED FFZpoolOptions* options, yyjson_m } } -void ffPrintZpoolHelpFormat(void) -{ - FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_ZPOOL_MODULE_NAME, "{3} / {4} ({5}, {6} frag)", FF_ZPOOL_NUM_FORMAT_ARGS, ((const char* []) { - "Zpool name - name", - "Zpool state - state", - "Size used - size-used", - "Size total - size-total", - "Size percentage num - size-percentage", - "Fragmentation percentage num - frag-percentage", - "Size percentage bar - size-percentage-bar", - "Fragmentation percentage bar - frag-percentage-bar", - })); -} +static FFModuleBaseInfo ffModuleInfo = { + .name = FF_ZPOOL_MODULE_NAME, + .description = "Print ZFS storage pools", + .parseCommandOptions = (void*) ffParseZpoolCommandOptions, + .parseJsonObject = (void*) ffParseZpoolJsonObject, + .printModule = (void*) ffPrintZpool, + .generateJsonResult = (void*) ffGenerateZpoolJsonResult, + .generateJsonConfig = (void*) ffGenerateZpoolJsonConfig, + .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { + {"Zpool name", "name"}, + {"Zpool state", "state"}, + {"Size used", "used"}, + {"Size total", "total"}, + {"Size percentage num", "used-percentage"}, + {"Fragmentation percentage num", "fragmentation-percentage"}, + {"Size percentage bar", "used-percentage-bar"}, + {"Fragmentation percentage bar", "fragmentation-percentage-bar"}, + })) +}; void ffInitZpoolOptions(FFZpoolOptions* options) { - ffOptionInitModuleBaseInfo( - &options->moduleInfo, - FF_ZPOOL_MODULE_NAME, - "Print ZFS storage pools", - ffParseZpoolCommandOptions, - ffParseZpoolJsonObject, - ffPrintZpool, - ffGenerateZpoolJsonResult, - ffPrintZpoolHelpFormat, - ffGenerateZpoolJsonConfig - ); + options->moduleInfo = ffModuleInfo; ffOptionInitModuleArg(&options->moduleArgs, "󱑛"); options->percent = (FFPercentageModuleConfig) { 50, 80, 0 }; } diff --git a/src/util/edidHelper.c b/src/util/edidHelper.c index 8c920bd30..d05c87361 100644 --- a/src/util/edidHelper.c +++ b/src/util/edidHelper.c @@ -65,8 +65,25 @@ bool ffEdidGetName(const uint8_t edid[128], FFstrbuf* name) void ffEdidGetPhysicalSize(const uint8_t edid[128], uint32_t* width, uint32_t* height) { - *width = edid[21] * 10; - *height = edid[22] * 10; + // Detailed Timing Descriptors + uint32_t dw = (((uint32_t) edid[68] & 0xF0) << 4) + edid[66]; + uint32_t dh = (((uint32_t) edid[68] & 0x0F) << 8) + edid[67]; + + // Basic Display Parameters + uint32_t bw = edid[21] * 10; + uint32_t bh = edid[22] * 10; + + // Some monitors report invalid data in DTD. See #1406 + if (abs((int)dw - (int)bw) < 10 && abs((int)dh - (int)bh) < 10) + { + *width = dw; + *height = dh; + } + else + { + *width = bw; + *height = bh; + } } void ffEdidGetSerialAndManufactureDate(const uint8_t edid[128], uint32_t* serial, uint16_t* year, uint16_t* week)