From cdd4afd105d0b81352014288cc259d4b74821a27 Mon Sep 17 00:00:00 2001 From: murat Date: Tue, 2 Jun 2026 00:38:01 +0300 Subject: [PATCH] define config schema and defaults --- main.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/main.cpp b/main.cpp index 87114db..da54a72 100644 --- a/main.cpp +++ b/main.cpp @@ -33,6 +33,17 @@ string getGPU(); string getRAM(); string getOsDate(); +enum class Module { + Distro, + Kernel, + Uptime, + Shell, + CPU, + GPU, + RAM, + OsDate, +}; + enum class Color { Red, RedLight, @@ -60,6 +71,62 @@ enum class Color { string color(Color c); +struct EnumHash { + template + size_t operator()(T v) const noexcept { + return static_cast(v); + } +}; + +// Built-in configuration defaults. These should preserve the current behavior +// when no config file is present (or when it's invalid). +struct Config { + vector modules; + bool logoEnabled = true; + + std::unordered_map labels; + std::unordered_map colors; +}; + +Config defaultConfig() { + Config cfg; + cfg.modules = { + Module::Distro, + Module::Kernel, + Module::Uptime, + Module::Shell, + Module::CPU, + Module::GPU, + Module::RAM, + Module::OsDate, + }; + + cfg.labels = { + {Module::Distro, " distro:"}, + {Module::Kernel, " kernel:"}, + {Module::Uptime, " uptime:"}, + {Module::Shell, " shell:"}, + {Module::CPU, "󰍛 CPU:"}, + {Module::GPU, "󰾲 GPU:"}, + {Module::RAM, " RAM:"}, + {Module::OsDate, " OS Date:"}, + }; + + cfg.colors = { + {Module::Distro, Color::Green}, + {Module::Kernel, Color::Magenta}, + {Module::Uptime, Color::Blue}, + {Module::Shell, Color::Magenta}, + {Module::CPU, Color::Yellow}, + {Module::GPU, Color::Yellow}, + {Module::RAM, Color::Red}, + {Module::OsDate, Color::Blue}, + }; + + cfg.logoEnabled = true; + return cfg; +} + struct DistroLogo { string id; Color color;