diff --git a/include/config.hpp.cmake b/include/config.hpp.cmake index 7b627f10..2fd4432d 100644 --- a/include/config.hpp.cmake +++ b/include/config.hpp.cmake @@ -2,10 +2,10 @@ #define APP_NAME "@PROJECT_NAME@" -#cmakedefine ENABLE_ALSA -#cmakedefine ENABLE_MPD -#cmakedefine ENABLE_NETWORK -#cmakedefine ENABLE_I3 +#cmakedefine ENABLE_ALSA true +#cmakedefine ENABLE_MPD true +#cmakedefine ENABLE_NETWORK true +#cmakedefine ENABLE_I3 true #define BUILDER_SPACE_TOKEN "%__" #define ALSA_SOUNDCARD "@SETTING_ALSA_SOUNDCARD@" diff --git a/src/bar.cpp b/src/bar.cpp index 97be5973..8ba76ec9 100644 --- a/src/bar.cpp +++ b/src/bar.cpp @@ -1,4 +1,5 @@ #include "bar.hpp" +#include "config.hpp" #include "registry.hpp" #include "services/builder.hpp" #include "utils/config.hpp" @@ -139,40 +140,29 @@ void Bar::load() std::unique_ptr module; auto type = config::get("module/"+ mod, "type"); - if (type == "internal/counter") module = std::make_unique(mod); - else if (type == "internal/backlight") module = std::make_unique(mod); - else if (type == "internal/battery") module = std::make_unique(mod); - else if (type == "internal/bspwm") module = std::make_unique(mod, this->opts->monitor->name); - else if (type == "internal/cpu") module = std::make_unique(mod); - else if (type == "internal/date") module = std::make_unique(mod); - else if (type == "internal/memory") module = std::make_unique(mod); - else if (type == "internal/network") -#ifdef ENABLE_NETWORK - module = std::make_unique(mod); -#else - throw CompiledWithoutModuleSupport("network"); -#endif - else if (type == "internal/i3") -#ifdef ENABLE_I3 - module = std::make_unique(mod, this->opts->monitor->name); -#else - throw CompiledWithoutModuleSupport("i3"); -#endif - else if (type == "internal/mpd") -#ifdef ENABLE_MPD - module = std::make_unique(mod); -#else - throw CompiledWithoutModuleSupport("mpd"); -#endif - else if (type == "internal/volume") -#ifdef ENABLE_ALSA - module = std::make_unique(mod); -#else - throw CompiledWithoutModuleSupport("volume"); -#endif - else if (type == "custom/text") module = std::make_unique(mod); - else if (type == "custom/script") module = std::make_unique(mod); - else if (type == "custom/menu") module = std::make_unique(mod); + if (!ENABLE_ALSA && type == "internal/volume") + throw CompiledWithoutModuleSupport(type); + if (!ENABLE_I3 && type == "internal/i3") + throw CompiledWithoutModuleSupport(type); + if (!ENABLE_MPD && type == "internal/mpd") + throw CompiledWithoutModuleSupport(type); + if (!ENABLE_NETWORK && type == "internal/network") + throw CompiledWithoutModuleSupport(type); + + if (type == "internal/counter") module = std::make_unique(mod); + else if (type == "internal/backlight") module = std::make_unique(mod); + else if (type == "internal/battery") module = std::make_unique(mod); + else if (type == "internal/bspwm") module = std::make_unique(mod, this->opts->monitor->name); + else if (type == "internal/cpu") module = std::make_unique(mod); + else if (type == "internal/date") module = std::make_unique(mod); + else if (type == "internal/memory") module = std::make_unique(mod); + else if (type == "internal/i3") module = std::make_unique(mod, this->opts->monitor->name); + else if (type == "internal/mpd") module = std::make_unique(mod); + else if (type == "internal/volume") module = std::make_unique(mod); + else if (type == "internal/network") module = std::make_unique(mod); + else if (type == "custom/text") module = std::make_unique(mod); + else if (type == "custom/script") module = std::make_unique(mod); + else if (type == "custom/menu") module = std::make_unique(mod); else throw ConfigurationError("Unknown module: "+ mod); vec.emplace_back(module->name());