ough
This commit is contained in:
parent
3ad961a571
commit
3b16fee5f4
28 changed files with 1242 additions and 1047 deletions
|
@ -2,10 +2,10 @@
|
|||
|
||||
#include <format> // std::{formatter, format_to}
|
||||
|
||||
#include "src/config/config.hpp" // Config
|
||||
#include "src/config/weather.hpp" // weather::Output
|
||||
|
||||
#include "util/defs.hpp"
|
||||
#include "util/error.hpp"
|
||||
#include "util/types.hpp"
|
||||
|
||||
struct Config;
|
||||
|
@ -58,34 +58,32 @@ struct std::formatter<BytesToGiB> : std::formatter<double> {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @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 {
|
||||
using NowPlayingResult = Option<Result<MediaInfo, util::error::DraconisError>>;
|
||||
|
||||
// clang-format off
|
||||
String date; ///< Current date (e.g., "April 26th"). Always expected to succeed.
|
||||
Result<String, util::error::DraconisError> host; ///< Host/product family (e.g., "MacBookPro18,3") or OS util::erroror.
|
||||
Result<String, util::error::DraconisError> kernel_version; ///< OS kernel version (e.g., "23.4.0") or OS error.
|
||||
Result<String, util::error::DraconisError> os_version; ///< OS pretty name (e.g., "macOS Sonoma 14.4.1") or OS error.
|
||||
Result<u64, util::error::DraconisError> mem_info; ///< Total physical RAM in bytes or OS error.
|
||||
Option<String> desktop_environment; ///< Detected desktop environment (e.g., "Aqua", "Plasma"). None if not detected/applicable.
|
||||
Option<String> window_manager; ///< Detected window manager (e.g., "Quartz Compositor", "KWin"). None if not detected/applicable.
|
||||
Result<DiskSpace, util::error::DraconisError> disk_usage; ///< Used/Total disk space for root filesystem or OS error.
|
||||
Option<String> shell; ///< Name of the current user shell (e.g., "zsh"). None if not detected.
|
||||
NowPlayingResult now_playing; ///< Optional: Result of fetching media info (MediaInfo on success, NowPlayingError on failure). None if disabled.
|
||||
Option<weather::Output> weather_info; ///< Optional: Weather information. None if disabled or util::erroror during fetch.
|
||||
// clang-format on
|
||||
|
||||
namespace os {
|
||||
/**
|
||||
* @brief Fetches all system data asynchronously.
|
||||
* @param config The application configuration.
|
||||
* @return A populated SystemData object.
|
||||
* @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.
|
||||
*/
|
||||
static fn fetchSystemData(const Config& config) -> SystemData;
|
||||
};
|
||||
struct SystemData {
|
||||
String date; ///< Current date (e.g., "April 26"). Always expected to succeed.
|
||||
Result<String, DracError> host; ///< Host/product family (e.g., "MacBook Air") or OS util::erroror.
|
||||
Result<String, DracError> kernelVersion; ///< OS kernel version (e.g., "6.14.4") or OS error.
|
||||
Result<String, DracError> osVersion; ///< OS pretty name (e.g., "Ubuntu 24.04.2 LTS") or OS error.
|
||||
Result<u64, DracError> memInfo; ///< Total physical RAM in bytes or OS error.
|
||||
Result<String, DracError> desktopEnv; ///< Desktop environment (e.g., "KDE") or None if not detected.
|
||||
Result<String, DracError> windowMgr; ///< Window manager (e.g., "KWin") or None if not detected.
|
||||
Result<DiskSpace, DracError> diskUsage; ///< Used/Total disk space for root filesystem or OS error.
|
||||
Result<String, DracError> shell; ///< Name of the current user shell (e.g., "zsh"). None if not detected.
|
||||
Result<u64, DracError> packageCount; ///< Total number of packages installed or OS error.
|
||||
Result<MediaInfo, DracError> nowPlaying; ///< Result of fetching media info.
|
||||
Result<weather::Output, DracError> 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue