draconis::core::system namespace provides a comprehensive cross-platform interface for querying system information. All functions return a Result type that contains either the requested data or an error.
Memory information
GetMemInfo
Fetches memory information for the system.Cache manager for storing results
Returns a
ResourceUsage struct containing:usedBytes: Currently used memory in bytestotalBytes: Total available memory in bytes
- Windows:
GlobalMemoryStatusEx - macOS:
host_statistics64/sysctlbyname("hw.memsize") - Linux:
sysinfo - FreeBSD/DragonFly:
sysctlbyname("hw.physmem") - NetBSD:
sysctlbyname("hw.physmem64") - Haiku:
get_system_info - SerenityOS: Reads from
/sys/kernel/memstat
- Platform-specific API calls fail (see source:~/workspace/source/include/Drac++/Core/System.hpp:29-36)
- On SerenityOS: JSON parsing fails or integer overflow occurs
Operating system information
GetOperatingSystem
Fetches the operating system version and details.Cache manager for storing results
Returns an
OSInfo struct containing:name: Operating system nameversion: Operating system version stringid: Operating system identifier
- Windows: Reads from registry at
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion, returns “Windows 11” ifbuildNumber >= 22000 - macOS: Parses
/System/Library/CoreServices/SystemVersion.plist, matches against known versions - Linux: Parses
PRETTY_NAMEfrom/etc/os-release - BSD: Parses
NAMEfrom/etc/os-release, falls back touname - Haiku: Reads from
/boot/system/lib/libbe.so - SerenityOS:
uname
- Windows: Registry operations fail or product name is empty
- macOS: CoreFoundation functions fail or version number is invalid
- Linux/BSD: Cannot open or parse
/etc/os-release - Haiku: Cannot read version info from system library
- SerenityOS:
unamecall fails
Desktop environment
GetDesktopEnvironment
Fetches the desktop environment or UI design language.Cache manager for storing results
Returns the desktop environment name (e.g., “KDE”, “Aqua”, “Fluent (Windows 11)”)
- Windows: UI design language based on build number from registry
- macOS: Hardcoded to “Aqua”
- Haiku: Hardcoded to “Haiku Desktop Environment”
- SerenityOS: Hardcoded to “SerenityOS Desktop”
- Other:
XDG_CURRENT_DESKTOPenvironment variable, falls back toDESKTOP_SESSION
- Windows: Registry read fails or build number parsing fails
- Other: Environment variables are not set
Window manager
GetWindowManager
Fetches the window manager or compositor.Cache manager for storing results
Returns the window manager name (e.g., “KWin”, “yabai”, “DWM”)
- Windows: “DWM” if composition is enabled, “Windows Manager (Basic)” otherwise
- macOS: Checks process tree for known window managers, falls back to “Quartz”
- Haiku: Hardcoded to “app_server”
- SerenityOS: Hardcoded to “WindowManager”
- Other: Detects X11 or Wayland compositor based on
WAYLAND_DISPLAYorDISPLAYenvironment variables
- Windows:
DwmIsCompositionEnabledfails - macOS:
sysctlcall fails or returns invalid data - Other: X11/Wayland support is disabled at compile time or detection fails
Shell
GetShell
Fetches the active shell.Cache manager for storing results
Returns the shell name (e.g., “zsh”, “bash”, “fish”)
- Windows: Checks
MSYSTEM,SHELL, orLOGINSHELLenvironment variables, falls back to process tree - SerenityOS:
getpwuid - Other:
SHELLenvironment variable
- Windows: No environment variables are set and process tree check fails
- SerenityOS:
getpwuidreturns null or shell path is empty - Other:
SHELLenvironment variable is not set
Host information
GetHost
Fetches the host or hostname.Cache manager for storing results
Returns the host/product name or hostname
- Windows: Reads from
HKEY_LOCAL_MACHINE\SYSTEM\HardwareConfig\Current - macOS:
sysctlbyname("hw.model")matched against known models - Linux: Reads from
/sys/class/dmi/id/product_family, falls back to/sys/class/dmi/id/product_name - FreeBSD/DragonFly:
kenv smbios.system.product, falls back tosysctlbyname("hw.model") - NetBSD:
sysctlbyname("machdep.dmi.system-product") - Haiku:
gethostname - SerenityOS:
gethostname
- Windows: Registry read fails
- macOS:
sysctlbynamefails or model not found in known models - Linux: Cannot read DMI product information
- BSD: System calls fail or return empty strings
- Haiku/SerenityOS:
gethostnamefails
CPU information
GetCPUModel
Fetches the CPU model string.Cache manager for storing results
Returns the CPU model string (e.g., “Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz”)
- Windows:
__cpuid(x86) /RegQueryValueExW(ARM64) - macOS:
sysctlbyname("machdep.cpu.brand_string") - Linux:
__get_cpuid(x86) //proc/cpuinfo(ARM64) - Other: To be implemented
- Platform-specific CPU detection fails
- Implementation not available for platform
GetCPUCores
Fetches the number of physical and logical CPU cores.Cache manager for storing results
Returns a
CPUCores struct containing:physical: Number of physical coreslogical: Number of logical cores (including hyperthreading)
- Windows:
GetLogicalProcessorInformation - Other: To be implemented
- Platform-specific API calls fail
- Implementation not available for platform
GPU information
GetGPUModel
Fetches the GPU model string.Cache manager for storing results
Returns the GPU model string (e.g., “NVIDIA GeForce RTX 3070”)
- Windows: DXGI
- macOS: Metal
- Other: To be implemented
- Windows: DXGI factory creation or adapter enumeration fails
- macOS: Metal device creation fails
- Other: Implementation not available for platform
Kernel information
GetKernelVersion
Fetches the kernel version.Cache manager for storing results
Returns the kernel version (e.g., “6.14.4”, “10.0.22000”)
- Windows: Version from
KUSER_SHARED_DATA(e.g., “10.0.22000”) - macOS:
sysctlbyname("kern.osrelease")(e.g., “22.3.0”) - Haiku:
get_system_info - Other Unix-like:
uname
- Windows: Failed to parse kernel shared data
- macOS:
sysctlbynamecall fails - Haiku:
get_system_infofails - Other:
unamecall fails or returns empty string
Disk information
GetDiskUsage
Fetches disk usage for the system drive.Cache manager for storing results
Returns a
ResourceUsage struct containing:usedBytes: Currently used disk space in bytestotalBytes: Total disk space in bytes
- Windows:
GetDiskFreeSpaceExW - Other:
statvfs
- Platform-specific API calls fail
GetDisks
Fetches information about all disk drives.Cache manager for storing results
Returns a vector of
DiskInfo structs, each containing:name: Drive/device name (e.g., “C:”, “/dev/sda1”)mountPoint: Mount path (e.g., “C:”, “/home”)filesystem: Filesystem type (e.g., “NTFS”, “ext4”, “APFS”)driveType: Drive type (e.g., “Fixed”, “Removable”, “Network”)totalBytes: Total capacity in bytesusedBytes: Used space in bytesisSystemDrive: Whether this is the system/boot drive
GetSystemDisk
Fetches information about the system/boot disk.Cache manager for storing results
Returns a
DiskInfo struct for the system diskGetDiskByPath
Fetches information about the disk containing a specific path.File system path to query
Cache manager for storing results
Returns a
DiskInfo struct for the disk containing the specified pathUptime
GetUptime
Fetches the system uptime.Returns the system uptime in seconds
- Windows:
GetTickCount64 - macOS:
sysctlbyname("kern.boottime") - Other: To be implemented
- Platform-specific API calls fail
- Implementation not available for platform
Display information
GetOutputs
Fetches information about all displays/monitors.Cache manager for storing results
Returns a vector of
DisplayInfo structs, each containing:id: Display identifierresolution.width: Width in pixelsresolution.height: Height in pixelsrefreshRate: Refresh rate in HzisPrimary: Whether this is the primary display
- Windows:
GetDisplayConfigBufferSizes - macOS:
CGGetActiveDisplayList - Other: To be implemented
- Platform-specific API calls fail
- Implementation not available for platform
GetPrimaryOutput
Fetches information about the primary display.Cache manager for storing results
Returns a
DisplayInfo struct for the primary display- Windows:
GetDisplayConfigBufferSizes - macOS:
CGGetActiveDisplayList - Other: To be implemented
- Platform-specific API calls fail
- No primary display found
- Implementation not available for platform
Network information
GetNetworkInterfaces
Fetches information about all network interfaces.Cache manager for storing results
Returns a vector of
NetworkInterface structs, each containing:name: Interface nameipv4Address: IPv4 address (optional)ipv6Address: IPv6 address (optional)macAddress: MAC address (optional)isUp: Whether the interface is upisLoopback: Whether the interface is a loopback interface
- Windows:
GetAdaptersAddresses - macOS:
getifaddrs - Other: To be implemented
- Platform-specific API calls fail
- Implementation not available for platform
GetPrimaryNetworkInterface
Fetches information about the primary network interface.Cache manager for storing results
Returns a
NetworkInterface struct for the primary interface- Windows:
GetAdaptersAddresses - macOS:
getifaddrs - Other: To be implemented
- Platform-specific API calls fail
- No primary interface found
- Implementation not available for platform
Battery information
GetBatteryInfo
Fetches battery information.Cache manager for storing results
Returns a
Battery struct containing:status: Battery status (Unknown, Charging, Discharging, Full, NotPresent)percentage: Battery charge percentage 0-100 (optional)timeRemaining: Estimated time remaining in seconds (optional)
- Windows:
GetSystemPowerStatus - macOS:
IOPSGetPowerSourceState - Other: To be implemented
- Platform-specific API calls fail
- Implementation not available for platform
Linux-specific functions
GetDistroID
Fetches the Linux distribution ID (Linux only).Cache manager for storing results
Returns the distribution ID from
/etc/os-release- Obtained from
/etc/os-release
- Cannot open or parse
/etc/os-release - Distribution ID field is missing