#pragma once #include // std::{formatter, format_to} #include "src/config/config.hpp" #include "src/config/weather.hpp" #include "src/util/defs.hpp" #include "src/util/types.hpp" struct Config; using util::types::u64, util::types::f64, util::types::String, util::types::Option, util::types::Result, util::types::MediaInfo, util::types::DiskSpace; /** * @struct BytesToGiB * @brief Helper struct to format a byte value to GiB (Gibibytes). * * Encapsulates a byte value and provides a custom formatter * to convert it to GiB for display purposes. */ struct BytesToGiB { u64 value; ///< The byte value to be converted. }; /// @brief Conversion factor from bytes to GiB constexpr u64 GIB = 1'073'741'824; /** * @brief Custom formatter for BytesToGiB. * * Allows formatting BytesToGiB values using std::format. * Outputs the value in GiB with two decimal places. * * @code{.cpp} * #include * #include "system_data.h" // Assuming BytesToGiB is defined here * * i32 main() { * BytesToGiB data_size{2'147'483'648}; // 2 GiB * String formatted = std::format("Size: {}", data_size); * std::println("{}", formatted); // formatted will be "Size: 2.00GiB" * return 0; * } * @endcode */ template <> struct std::formatter : std::formatter { /** * @brief Formats the BytesToGiB value. * @param BTG The BytesToGiB instance to format. * @param ctx The formatting context. * @return An iterator to the end of the formatted output. */ fn format(const BytesToGiB& BTG, auto& ctx) const { return std::format_to(ctx.out(), "{:.2f}GiB", static_cast(BTG.value) / GIB); } }; namespace os { /** * @struct SystemData * @brief Holds various pieces of system information collected from the OS. * * This structure aggregates information about the system, * in order to display it at all at once during runtime. */ struct SystemData { Result date; ///< Current date (e.g., "April 26th"). Result host; ///< Host/product family (e.g., "MacBook Air"). Result kernelVersion; ///< OS kernel version (e.g., "6.14.4"). Result osVersion; ///< OS pretty name (e.g., "Ubuntu 24.04.2 LTS"). Result memInfo; ///< Total physical RAM in bytes. Result desktopEnv; ///< Desktop environment (e.g., "KDE"). Result windowMgr; ///< Window manager (e.g., "KWin"). Result diskUsage; ///< Used/Total disk space for root filesystem. Result shell; ///< Name of the current user shell (e.g., "zsh"). Result packageCount; ///< Total number of packages installed. Result nowPlaying; ///< Result of fetching media info. Result weather; ///< Result of fetching weather info. /** * @brief Constructs a SystemData object and initializes its members. * @param config The configuration object containing settings for the system data. */ explicit SystemData(const Config& config); }; } // namespace os