Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
552 changes: 69 additions & 483 deletions project_binary_fetch/binary_fetch_v1/AsciiArt.cpp

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions project_binary_fetch/binary_fetch_v1/AsciiArt.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/*
---------------------------------------------------------
AsciiArt Utilities � Helper Functions (Declarations)
AsciiArt Utilities � Helper Functions (Declarations)
---------------------------------------------------------

These helpers deal with visual correctness when printing
Expand Down Expand Up @@ -46,7 +46,7 @@ void sanitizeLeadingInvisible(std::string& s);
- Reporting how tall and wide the art is
- Providing safe access to art lines for real-time display

This class does NOT print anything itself � LivePrinter
This class does NOT print anything itself � LivePrinter
handles actual on-screen printing.
*/
class AsciiArt {
Expand Down Expand Up @@ -94,6 +94,7 @@ class AsciiArt {

// Internal helper: Load art from a specific file path
bool loadArtFromPath(const std::string& filepath);
bool loadArtFromString(const std::string& artContent);
};


Expand Down Expand Up @@ -121,7 +122,7 @@ class LivePrinter {
// Each call prints the next art line (or blank padding).
void push(const std::string& infoLine);

// Same as push("") � convenient for spacing
// Same as push("") � convenient for spacing
void pushBlank();

// After finishing all info lines, print any remaining
Expand Down
193 changes: 193 additions & 0 deletions project_binary_fetch/binary_fetch_v1/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
cmake_minimum_required(VERSION 3.16)
project(BinaryFetch VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Platform detection
if(WIN32)
set(PLATFORM_WINDOWS TRUE)
add_definitions(-DPLATFORM_WINDOWS=1)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(PLATFORM_LINUX TRUE)
add_definitions(-DPLATFORM_LINUX=1)
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(PLATFORM_FREEBSD TRUE)
add_definitions(-DPLATFORM_FREEBSD=1)
else()
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
endif()

# Static linking options
option(BUILD_STATIC "Build statically linked binary" ON)

if(BUILD_STATIC)
if(PLATFORM_LINUX OR PLATFORM_FREEBSD)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
elseif(PLATFORM_WINDOWS)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()

# Common source files (platform-agnostic logic)
set(COMMON_SOURCES
main.cpp
AsciiArt.cpp
ConfigReader.cpp
Helpers.cpp
TimeInfo.cpp
personalization_info.cpp
DistroDetector.cpp
)

# Windows-specific sources
set(WINDOWS_SOURCES
OSInfo.cpp
CPUInfo.cpp
MemoryInfo.cpp
GPUInfo.cpp
StorageInfo.cpp
NetworkInfo.cpp
DisplayInfo.cpp
UserInfo.cpp
SystemInfo.cpp
PerformanceInfo.cpp
ExtraInfo.cpp
DtailedGPUInfo.cpp
DetailedScreen.cpp
ConsoleUtils.cpp
CompactOS.cpp
CompactCPU.cpp
CompactMemory.cpp
CompactGPU.cpp
CompactScreen.cpp
CompactSystem.cpp
CompactUser.cpp
CompactNetwork.cpp
CompactPerformance.cpp
CompactAudio.cpp
compact_disk_info.cpp
)

# POSIX/Unix sources (Linux + FreeBSD shared)
set(POSIX_SOURCES
platform/posix/UserInfoPosix.cpp
platform/posix/CompactOSPosix.cpp
platform/posix/CompactCPUPosix.cpp
platform/posix/CompactMemoryPosix.cpp
platform/posix/CompactGPUPosix.cpp
platform/posix/CompactScreenPosix.cpp
platform/posix/CompactNetworkPosix.cpp
platform/posix/CompactUserPosix.cpp
platform/posix/CompactPerformancePosix.cpp
platform/posix/CompactSystemPosix.cpp
platform/posix/compact_disk_infoPosix.cpp
platform/posix/CompactAudioPosix.cpp
)

# Linux-specific sources
set(LINUX_SOURCES
platform/linux/OSInfoLinux.cpp
platform/linux/CPUInfoLinux.cpp
platform/linux/MemoryInfoLinux.cpp
platform/linux/GPUInfoLinux.cpp
platform/linux/StorageInfoLinux.cpp
platform/linux/NetworkInfoLinux.cpp
platform/linux/DisplayInfoLinux.cpp
platform/linux/SystemInfoLinux.cpp
platform/linux/PerformanceInfoLinux.cpp
)

# FreeBSD-specific sources
set(FREEBSD_SOURCES
platform/freebsd/OSInfoFreeBSD.cpp
platform/freebsd/CPUInfoFreeBSD.cpp
platform/freebsd/MemoryInfoFreeBSD.cpp
platform/freebsd/GPUInfoFreeBSD.cpp
platform/freebsd/StorageInfoFreeBSD.cpp
platform/freebsd/NetworkInfoFreeBSD.cpp
platform/freebsd/DisplayInfoFreeBSD.cpp
platform/freebsd/SystemInfoFreeBSD.cpp
platform/freebsd/PerformanceInfoFreeBSD.cpp
platform/freebsd/AudioInfoFreeBSD.cpp
)

# POSIX-specific compact sources (replaces Windows versions)
set(POSIX_COMPACT_SOURCES
platform/posix/ExtraInfoPosix.cpp
platform/posix/DetailedGPUInfoPosix.cpp
platform/posix/DetailedScreenPosix.cpp
platform/posix/ConsoleUtilsPosix.cpp
)

# Windows compact-related sources
set(WINDOWS_COMPACT_SOURCES
ExtraInfo.cpp
DtailedGPUInfo.cpp
DetailedScreen.cpp
ConsoleUtils.cpp
)

# Select platform sources
if(PLATFORM_WINDOWS)
set(PLATFORM_SOURCES ${WINDOWS_SOURCES} ${WINDOWS_COMPACT_SOURCES})
set(PLATFORM_LIBS
wbemuuid
pdh
iphlpapi
ws2_32
wlanapi
winhttp
dxgi
d3d12
netapi32
setupapi
cfgmgr32
Shcore
ole32
oleaut32
)
elseif(PLATFORM_LINUX)
set(PLATFORM_SOURCES ${POSIX_SOURCES} ${LINUX_SOURCES} ${POSIX_COMPACT_SOURCES})
set(PLATFORM_LIBS pthread)
elseif(PLATFORM_FREEBSD)
set(PLATFORM_SOURCES ${POSIX_SOURCES} ${FREEBSD_SOURCES} ${POSIX_COMPACT_SOURCES})
set(PLATFORM_LIBS pthread)
endif()

# Create executable
add_executable(binaryfetch ${COMMON_SOURCES} ${PLATFORM_SOURCES})

# Include directories
target_include_directories(binaryfetch PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/nlohmann
${CMAKE_CURRENT_SOURCE_DIR}/platform
)

# Link libraries
target_link_libraries(binaryfetch PRIVATE ${PLATFORM_LIBS})

# Compiler warnings
if(MSVC)
target_compile_options(binaryfetch PRIVATE /W4)
else()
target_compile_options(binaryfetch PRIVATE -Wall -Wextra -Wpedantic)
endif()

# Install
install(TARGETS binaryfetch RUNTIME DESTINATION bin)

# Platform-specific install paths for config
if(PLATFORM_LINUX)
install(FILES Default_BinaryFetch_Config.json DESTINATION share/binaryfetch RENAME BinaryFetch_Config.json)
install(FILES Default_Ascii_Art.txt DESTINATION share/binaryfetch RENAME BinaryArt.txt)
elseif(PLATFORM_FREEBSD)
install(FILES Default_BinaryFetch_Config.json DESTINATION share/binaryfetch RENAME BinaryFetch_Config.json)
install(FILES Default_Ascii_Art.txt DESTINATION share/binaryfetch RENAME BinaryArt.txt)
endif()

message(STATUS "Building BinaryFetch for: ${CMAKE_SYSTEM_NAME}")
message(STATUS "Static linking: ${BUILD_STATIC}")
16 changes: 15 additions & 1 deletion project_binary_fetch/binary_fetch_v1/CompactOS.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
#pragma once
#include <iostream>
#include <string>

#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#include <VersionHelpers.h>
using namespace std;
#endif

#if defined(__linux__)
#include <sys/utsname.h>
#endif

#if defined(__FreeBSD__)
#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/time.h>
#endif

class CompactOS {
public:
std::string getOSName();
Expand Down
3 changes: 3 additions & 0 deletions project_binary_fetch/binary_fetch_v1/CompactPerformance.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#pragma once

#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#endif

class CompactPerformance {
public:
Expand Down
15 changes: 11 additions & 4 deletions project_binary_fetch/binary_fetch_v1/CompactScreen.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#pragma once
#pragma once

#include <string>
#include <vector>

#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#endif

struct ScreenInfo {
std::string name; // Friendly display name (e.g., "ASUS VG27AQ")
Expand Down Expand Up @@ -41,13 +44,17 @@ class CompactScreen {
private:
std::vector<ScreenInfo> screens;

// Population methods
#if defined(_WIN32) || defined(_WIN64)
// Windows-specific population methods
bool populateFromDXGI();
bool enrichWithNVAPI();
bool enrichWithADL();

// Helper to get friendly name from EDID
std::string getFriendlyNameFromEDID(const std::wstring& deviceName);
#else
// POSIX population methods
bool populateFromXrandr();
bool populateFromDRM();
#endif

// Helper to parse EDID for native resolution and name
struct EDIDInfo {
Expand Down
Loading