From 0caa30683c4c89a7ab8d8f58236ea00be3c90e55 Mon Sep 17 00:00:00 2001 From: dvermd <315743+dvermd@users.noreply.github.com> Date: Mon, 1 May 2023 14:58:52 +0200 Subject: [PATCH] Remove config singleton (#2951) * Remove unused function * Refactor deprecation warning * Modules take config as parameter instead of using the singleton * Bar take config as parameter instead of using the singleton * Renderer take config as parameter instead of using the singleton * Legacy Tray Manager take config as parameter instead of using the singleton * Screen take config as parameter instead of using the singleton * Controller take config as parameter instead of using the singleton * Remove the config singleton * Apply review suggestion Co-authored-by: Patrick Ziegler * Apply style suggestion Co-authored-by: Patrick Ziegler * Apply style suggestion Co-authored-by: Patrick Ziegler * Apply style suggestion Co-authored-by: Patrick Ziegler * Apply style suggestion Co-authored-by: Patrick Ziegler * Apply style suggestion Co-authored-by: Patrick Ziegler * Apply style suggestion Co-authored-by: Patrick Ziegler * Apply style suggestion Co-authored-by: Patrick Ziegler * Apply style suggestion Co-authored-by: Patrick Ziegler * Apply style suggestion Co-authored-by: Patrick Ziegler --------- Co-authored-by: Patrick Ziegler --- include/components/bar.hpp | 2 +- include/components/config.hpp | 23 ++------------------- include/components/config_parser.hpp | 4 ++-- include/components/controller.hpp | 2 +- include/components/renderer.hpp | 2 +- include/components/screen.hpp | 2 +- include/modules/alsa.hpp | 2 +- include/modules/backlight.hpp | 2 +- include/modules/battery.hpp | 2 +- include/modules/bspwm.hpp | 2 +- include/modules/counter.hpp | 2 +- include/modules/cpu.hpp | 2 +- include/modules/date.hpp | 2 +- include/modules/fs.hpp | 2 +- include/modules/github.hpp | 2 +- include/modules/i3.hpp | 2 +- include/modules/ipc.hpp | 2 +- include/modules/memory.hpp | 2 +- include/modules/menu.hpp | 2 +- include/modules/meta/base.hpp | 3 ++- include/modules/meta/base.inl | 5 ++--- include/modules/meta/factory.hpp | 3 ++- include/modules/mpd.hpp | 2 +- include/modules/network.hpp | 2 +- include/modules/pulseaudio.hpp | 2 +- include/modules/script.hpp | 2 +- include/modules/temperature.hpp | 2 +- include/modules/text.hpp | 2 +- include/modules/tray.hpp | 2 +- include/modules/unsupported.hpp | 2 +- include/modules/xbacklight.hpp | 2 +- include/modules/xkeyboard.hpp | 2 +- include/modules/xwindow.hpp | 2 +- include/modules/xworkspaces.hpp | 2 +- include/x11/legacy_tray_manager.hpp | 3 ++- src/components/bar.cpp | 10 ++++----- src/components/config.cpp | 31 +++++++++------------------- src/components/config_parser.cpp | 21 ++++++++----------- src/components/controller.cpp | 18 ++++++++-------- src/components/renderer.cpp | 4 ++-- src/components/screen.cpp | 4 ++-- src/main.cpp | 6 +++--- src/modules/alsa.cpp | 3 ++- src/modules/backlight.cpp | 4 ++-- src/modules/battery.cpp | 4 ++-- src/modules/bspwm.cpp | 3 ++- src/modules/counter.cpp | 4 ++-- src/modules/cpu.cpp | 3 ++- src/modules/date.cpp | 3 ++- src/modules/fs.cpp | 3 ++- src/modules/github.cpp | 3 ++- src/modules/i3.cpp | 3 ++- src/modules/ipc.cpp | 3 ++- src/modules/memory.cpp | 3 ++- src/modules/menu.cpp | 3 ++- src/modules/meta/factory.cpp | 10 ++++----- src/modules/mpd.cpp | 3 ++- src/modules/network.cpp | 4 ++-- src/modules/pulseaudio.cpp | 4 ++-- src/modules/script.cpp | 4 ++-- src/modules/temperature.cpp | 4 ++-- src/modules/text.cpp | 3 ++- src/modules/tray.cpp | 4 ++-- src/modules/xbacklight.cpp | 4 ++-- src/modules/xkeyboard.cpp | 4 ++-- src/modules/xwindow.cpp | 4 ++-- src/modules/xworkspaces.cpp | 4 ++-- src/x11/legacy_tray_manager.cpp | 4 +--- 68 files changed, 135 insertions(+), 156 deletions(-) diff --git a/include/components/bar.hpp b/include/components/bar.hpp index 43e9b2f5..3d800a1e 100644 --- a/include/components/bar.hpp +++ b/include/components/bar.hpp @@ -37,7 +37,7 @@ class bar : public xpp::event::sink { public: using make_type = unique_ptr; - static make_type make(eventloop::loop&, bool only_initialize_values = false); + static make_type make(eventloop::loop&, const config&, bool only_initialize_values = false); explicit bar(connection&, signal_emitter&, const config&, const logger&, eventloop::loop&, unique_ptr&&, unique_ptr&&, unique_ptr&&, bool only_initialize_values); diff --git a/include/components/config.hpp b/include/components/config.hpp index d0be66d4..971c2f3e 100644 --- a/include/components/config.hpp +++ b/include/components/config.hpp @@ -24,10 +24,7 @@ using file_list = vector; class config { public: - using make_type = const config&; - static make_type make(string path = "", string bar = ""); - - explicit config(const logger& logger, string&& path = "", string&& bar = "") + explicit config(const logger& logger, string&& path, string&& bar) : m_log(logger), m_file(move(path)), m_barname(move(bar)){}; const string& filepath() const; @@ -46,7 +43,7 @@ class config { file_list get_included_files() const; - void warn_deprecated(const string& section, const string& key, string replacement) const; + void warn_deprecated(const string& section, const string& key, string replacement = "") const; /** * Returns true if a given parameter exists @@ -212,8 +209,6 @@ class config { return default_value; } - void ignore_key(const string& section, const string& key) const; - /** * Attempt to load value using the deprecated key name. If successful show a * warning message. If it fails load the value using the new key and given @@ -234,20 +229,6 @@ class config { } } - /** - * @see deprecated - */ - template - T deprecated_list(const string& section, const string& old, const string& newkey, const vector& fallback) const { - try { - vector value{get_list(section, old)}; - warn_deprecated(section, old, newkey); - return value; - } catch (const key_error& err) { - return get_list(section, newkey, fallback); - } - } - protected: void copy_inherited(); diff --git a/include/components/config_parser.hpp b/include/components/config_parser.hpp index f580f0eb..3cd6eab9 100644 --- a/include/components/config_parser.hpp +++ b/include/components/config_parser.hpp @@ -105,7 +105,7 @@ class config_parser { * @throws syntax_error If there was any kind of syntax error * @throws parser_error If aynthing else went wrong */ - config::make_type parse(string barname); + config parse(string barname); protected: /** @@ -229,7 +229,7 @@ class config_parser { /** * @brief Absolute path to the main config file */ - string m_config; + string m_config_file; /** * @brief List of all the lines in the config (with included files) diff --git a/include/components/controller.hpp b/include/components/controller.hpp index 1fc5ebc4..449cd838 100644 --- a/include/components/controller.hpp +++ b/include/components/controller.hpp @@ -39,7 +39,7 @@ class controller : public signal_receiver { public: using make_type = unique_ptr; - static make_type make(bool has_ipc, eventloop::loop&); + static make_type make(bool has_ipc, eventloop::loop&, const config&); explicit controller(connection&, signal_emitter&, const logger&, const config&, bool has_ipc, eventloop::loop&); ~controller(); diff --git a/include/components/renderer.hpp b/include/components/renderer.hpp index 87b9f86d..21eca95c 100644 --- a/include/components/renderer.hpp +++ b/include/components/renderer.hpp @@ -46,7 +46,7 @@ class renderer : public renderer_interface, public signal_receiver { public: using make_type = unique_ptr; - static make_type make(const bar_settings& bar, tags::action_context& action_ctxt); + static make_type make(const bar_settings& bar, tags::action_context& action_ctxt, const config&); explicit renderer(connection& conn, signal_emitter& sig, const config&, const logger& logger, const bar_settings& bar, background_manager& background_manager, tags::action_context& action_ctxt); diff --git a/include/components/screen.hpp b/include/components/screen.hpp index aa4ad55c..95e41e08 100644 --- a/include/components/screen.hpp +++ b/include/components/screen.hpp @@ -19,7 +19,7 @@ class signal_emitter; class screen : public xpp::event::sink { public: using make_type = unique_ptr; - static make_type make(); + static make_type make(const config&); explicit screen(connection& conn, signal_emitter& emitter, const logger& logger, const config& conf); ~screen(); diff --git a/include/modules/alsa.hpp b/include/modules/alsa.hpp index dd28b03a..3a86da85 100644 --- a/include/modules/alsa.hpp +++ b/include/modules/alsa.hpp @@ -20,7 +20,7 @@ namespace modules { class alsa_module : public event_module { public: - explicit alsa_module(const bar_settings&, string); + explicit alsa_module(const bar_settings&, string, const config&); void teardown(); bool has_event(); diff --git a/include/modules/backlight.hpp b/include/modules/backlight.hpp index 0c86215e..f1db0fe7 100644 --- a/include/modules/backlight.hpp +++ b/include/modules/backlight.hpp @@ -20,7 +20,7 @@ namespace modules { string get_output(); public: - explicit backlight_module(const bar_settings&, string); + explicit backlight_module(const bar_settings&, string, const config&); void idle(); bool on_event(const inotify_event& event); diff --git a/include/modules/battery.hpp b/include/modules/battery.hpp index e1d54d8f..bd6ef788 100644 --- a/include/modules/battery.hpp +++ b/include/modules/battery.hpp @@ -46,7 +46,7 @@ namespace modules { using consumption_reader = mutex_wrapper>; public: - explicit battery_module(const bar_settings&, string); + explicit battery_module(const bar_settings&, string, const config&); void start() override; void teardown(); diff --git a/include/modules/bspwm.hpp b/include/modules/bspwm.hpp index 002505cd..9fb20ba6 100644 --- a/include/modules/bspwm.hpp +++ b/include/modules/bspwm.hpp @@ -39,7 +39,7 @@ namespace modules { }; public: - explicit bspwm_module(const bar_settings&, string); + explicit bspwm_module(const bar_settings&, string, const config&); void stop() override; bool has_event(); diff --git a/include/modules/counter.hpp b/include/modules/counter.hpp index a386185d..a92d98f6 100644 --- a/include/modules/counter.hpp +++ b/include/modules/counter.hpp @@ -7,7 +7,7 @@ POLYBAR_NS namespace modules { class counter_module : public timer_module { public: - explicit counter_module(const bar_settings&, string); + explicit counter_module(const bar_settings&, string, const config&); bool update(); bool build(builder* builder, const string& tag) const; diff --git a/include/modules/cpu.hpp b/include/modules/cpu.hpp index c8cbc75e..fff25da0 100644 --- a/include/modules/cpu.hpp +++ b/include/modules/cpu.hpp @@ -20,7 +20,7 @@ namespace modules { class cpu_module : public timer_module { public: - explicit cpu_module(const bar_settings&, string); + explicit cpu_module(const bar_settings&, string, const config&); bool update(); string get_format() const; diff --git a/include/modules/date.hpp b/include/modules/date.hpp index 296ec276..cd49d643 100644 --- a/include/modules/date.hpp +++ b/include/modules/date.hpp @@ -12,7 +12,7 @@ POLYBAR_NS namespace modules { class date_module : public timer_module { public: - explicit date_module(const bar_settings&, string); + explicit date_module(const bar_settings&, string, const config&); bool update(); bool build(builder* builder, const string& tag) const; diff --git a/include/modules/fs.hpp b/include/modules/fs.hpp index c67663ce..5fb880d2 100644 --- a/include/modules/fs.hpp +++ b/include/modules/fs.hpp @@ -35,7 +35,7 @@ namespace modules { */ class fs_module : public timer_module { public: - explicit fs_module(const bar_settings&, string); + explicit fs_module(const bar_settings&, string, const config&); bool update(); string get_format() const; diff --git a/include/modules/github.hpp b/include/modules/github.hpp index 57a17083..e9a8d4c0 100644 --- a/include/modules/github.hpp +++ b/include/modules/github.hpp @@ -14,7 +14,7 @@ namespace modules { */ class github_module : public timer_module { public: - explicit github_module(const bar_settings&, string); + explicit github_module(const bar_settings&, string, const config&); bool update(); bool build(builder* builder, const string& tag) const; diff --git a/include/modules/i3.hpp b/include/modules/i3.hpp index 951c1865..8cfb7170 100644 --- a/include/modules/i3.hpp +++ b/include/modules/i3.hpp @@ -44,7 +44,7 @@ namespace modules { }; public: - explicit i3_module(const bar_settings&, string); + explicit i3_module(const bar_settings&, string, const config&); void stop() override; bool has_event(); diff --git a/include/modules/ipc.hpp b/include/modules/ipc.hpp index 9acc3b3e..ce2f63a4 100644 --- a/include/modules/ipc.hpp +++ b/include/modules/ipc.hpp @@ -24,7 +24,7 @@ namespace modules { }; public: - explicit ipc_module(const bar_settings&, string); + explicit ipc_module(const bar_settings&, string, const config&); void start() override; void update(); diff --git a/include/modules/memory.hpp b/include/modules/memory.hpp index a42ca40b..90160b8e 100644 --- a/include/modules/memory.hpp +++ b/include/modules/memory.hpp @@ -10,7 +10,7 @@ namespace modules { enum class memory_state { NORMAL = 0, WARN }; class memory_module : public timer_module { public: - explicit memory_module(const bar_settings&, string); + explicit memory_module(const bar_settings&, string, const config&); bool update(); string get_format() const; diff --git a/include/modules/menu.hpp b/include/modules/menu.hpp index 9d414ed7..8255e2b5 100644 --- a/include/modules/menu.hpp +++ b/include/modules/menu.hpp @@ -17,7 +17,7 @@ namespace modules { }; public: - explicit menu_module(const bar_settings&, string); + explicit menu_module(const bar_settings&, string, const config&); bool build(builder* builder, const string& tag) const; void update() {} diff --git a/include/modules/meta/base.hpp b/include/modules/meta/base.hpp index 78b4fc17..91dacc97 100644 --- a/include/modules/meta/base.hpp +++ b/include/modules/meta/base.hpp @@ -8,6 +8,7 @@ #include #include "common.hpp" +#include "components/config.hpp" #include "components/types.hpp" #include "errors.hpp" #include "utils/concurrency.hpp" @@ -142,7 +143,7 @@ namespace modules { template class module : public module_interface { public: - module(const bar_settings& bar, string name); + module(const bar_settings& bar, string name, const config&); ~module() noexcept; static constexpr auto EVENT_MODULE_TOGGLE = "module_toggle"; diff --git a/include/modules/meta/base.inl b/include/modules/meta/base.inl index ffbe9250..f80c7782 100644 --- a/include/modules/meta/base.inl +++ b/include/modules/meta/base.inl @@ -2,7 +2,6 @@ #include #include "components/builder.hpp" -#include "components/config.hpp" #include "components/logger.hpp" #include "events/signal.hpp" #include "events/signal_emitter.hpp" @@ -16,11 +15,11 @@ namespace modules { // module public {{{ template - module::module(const bar_settings& bar, string name) + module::module(const bar_settings& bar, string name, const config& conf) : m_sig(signal_emitter::make()) , m_bar(bar) , m_log(logger::make()) - , m_conf(config::make()) + , m_conf(conf) , m_router(make_unique()) , m_name("module/" + name) , m_name_raw(name) diff --git a/include/modules/meta/factory.hpp b/include/modules/meta/factory.hpp index 0c3c96ba..b1c0cf95 100644 --- a/include/modules/meta/factory.hpp +++ b/include/modules/meta/factory.hpp @@ -17,8 +17,9 @@ namespace modules { * @param bar An instance of the @ref bar_settings * @param module_name The user-specified module name * @param log A @ref logger instance + * @param config A @ref config instance */ - module_t make_module(string&& type, const bar_settings& bar, string module_name, const logger& log); + module_t make_module(string&& type, const bar_settings& bar, string module_name, const logger& log, const config& config); } // namespace modules POLYBAR_NS_END diff --git a/include/modules/mpd.hpp b/include/modules/mpd.hpp index 5c44ae1d..c11e0857 100644 --- a/include/modules/mpd.hpp +++ b/include/modules/mpd.hpp @@ -13,7 +13,7 @@ using namespace mpd; namespace modules { class mpd_module : public event_module { public: - explicit mpd_module(const bar_settings&, string); + explicit mpd_module(const bar_settings&, string, const config&); void teardown(); inline bool connected() const; diff --git a/include/modules/network.hpp b/include/modules/network.hpp index fc7ce594..c69e1559 100644 --- a/include/modules/network.hpp +++ b/include/modules/network.hpp @@ -11,7 +11,7 @@ namespace modules { class network_module : public timer_module { public: - explicit network_module(const bar_settings&, string); + explicit network_module(const bar_settings&, string, const config&); void teardown(); bool update(); diff --git a/include/modules/pulseaudio.hpp b/include/modules/pulseaudio.hpp index 37868f39..897f4d73 100644 --- a/include/modules/pulseaudio.hpp +++ b/include/modules/pulseaudio.hpp @@ -13,7 +13,7 @@ namespace modules { class pulseaudio_module : public event_module { public: - explicit pulseaudio_module(const bar_settings&, string); + explicit pulseaudio_module(const bar_settings&, string, const config&); void teardown(); bool has_event(); diff --git a/include/modules/script.hpp b/include/modules/script.hpp index 969af692..6f8e7859 100644 --- a/include/modules/script.hpp +++ b/include/modules/script.hpp @@ -10,7 +10,7 @@ POLYBAR_NS namespace modules { class script_module : public module { public: - explicit script_module(const bar_settings&, string); + explicit script_module(const bar_settings&, string, const config&); void start() override; void stop() override; diff --git a/include/modules/temperature.hpp b/include/modules/temperature.hpp index f59c1abe..c7fc3e4c 100644 --- a/include/modules/temperature.hpp +++ b/include/modules/temperature.hpp @@ -12,7 +12,7 @@ namespace modules { class temperature_module : public timer_module { public: - explicit temperature_module(const bar_settings&, string); + explicit temperature_module(const bar_settings&, string, const config&); bool update(); string get_format() const; diff --git a/include/modules/text.hpp b/include/modules/text.hpp index a9507721..fba16f63 100644 --- a/include/modules/text.hpp +++ b/include/modules/text.hpp @@ -7,7 +7,7 @@ POLYBAR_NS namespace modules { class text_module : public static_module { public: - explicit text_module(const bar_settings&, string); + explicit text_module(const bar_settings&, string, const config&); void update() {} string get_format() const; diff --git a/include/modules/tray.hpp b/include/modules/tray.hpp index 0d1c7467..7cf60401 100644 --- a/include/modules/tray.hpp +++ b/include/modules/tray.hpp @@ -9,7 +9,7 @@ POLYBAR_NS namespace modules { class tray_module : public static_module { public: - explicit tray_module(const bar_settings& bar_settings, string name_); + explicit tray_module(const bar_settings& bar_settings, string name_, const config&); string get_format() const; void start() override; diff --git a/include/modules/unsupported.hpp b/include/modules/unsupported.hpp index b03b3cb7..788b4f4f 100644 --- a/include/modules/unsupported.hpp +++ b/include/modules/unsupported.hpp @@ -11,7 +11,7 @@ namespace modules { #define DEFINE_UNSUPPORTED_MODULE(MODULE_NAME, MODULE_TYPE) \ class MODULE_NAME : public module_interface { \ public: \ - MODULE_NAME(const bar_settings, string) { \ + MODULE_NAME(const bar_settings, string, const config&) { \ throw application_error("No built-in support for '" + string{MODULE_TYPE} + "'"); \ } \ static constexpr auto TYPE = MODULE_TYPE; \ diff --git a/include/modules/xbacklight.hpp b/include/modules/xbacklight.hpp index 796a590e..e18295bf 100644 --- a/include/modules/xbacklight.hpp +++ b/include/modules/xbacklight.hpp @@ -24,7 +24,7 @@ namespace modules { */ class xbacklight_module : public static_module, public event_handler { public: - explicit xbacklight_module(const bar_settings& bar, string name_); + explicit xbacklight_module(const bar_settings& bar, string name_, const config&); void update(); string get_output(); diff --git a/include/modules/xkeyboard.hpp b/include/modules/xkeyboard.hpp index 2014b65c..75b83083 100644 --- a/include/modules/xkeyboard.hpp +++ b/include/modules/xkeyboard.hpp @@ -21,7 +21,7 @@ namespace modules { : public static_module, public event_handler { public: - explicit xkeyboard_module(const bar_settings& bar, string name_); + explicit xkeyboard_module(const bar_settings& bar, string name_, const config&); string get_output(); void update(); diff --git a/include/modules/xwindow.hpp b/include/modules/xwindow.hpp index 8b447031..185ac611 100644 --- a/include/modules/xwindow.hpp +++ b/include/modules/xwindow.hpp @@ -33,7 +33,7 @@ namespace modules { class xwindow_module : public static_module, public event_handler { public: enum class state { NONE, ACTIVE, EMPTY }; - explicit xwindow_module(const bar_settings&, string); + explicit xwindow_module(const bar_settings&, string, const config&); void update(); bool build(builder* builder, const string& tag) const; diff --git a/include/modules/xworkspaces.hpp b/include/modules/xworkspaces.hpp index 364eae39..605f9af6 100644 --- a/include/modules/xworkspaces.hpp +++ b/include/modules/xworkspaces.hpp @@ -44,7 +44,7 @@ namespace modules { */ class xworkspaces_module : public static_module, public event_handler { public: - explicit xworkspaces_module(const bar_settings& bar, string name_); + explicit xworkspaces_module(const bar_settings& bar, string name_, const config&); void update(); string get_output(); diff --git a/include/x11/legacy_tray_manager.hpp b/include/x11/legacy_tray_manager.hpp index 996dcece..9ac61f7e 100644 --- a/include/x11/legacy_tray_manager.hpp +++ b/include/x11/legacy_tray_manager.hpp @@ -9,6 +9,7 @@ #include "cairo/context.hpp" #include "cairo/surface.hpp" #include "common.hpp" +#include "components/config.hpp" #include "components/logger.hpp" #include "components/types.hpp" #include "events/signal_fwd.hpp" @@ -134,7 +135,7 @@ class tray_manager const tray_settings settings() const; - void setup(const string& tray_module_name); + void setup(const config&, const string& tray_module_name); void activate(); void activate_delayed(chrono::duration delay = 1s); void deactivate(bool clear_selection = true); diff --git a/src/components/bar.cpp b/src/components/bar.cpp index e419b803..d47c6dfc 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -38,17 +38,17 @@ using namespace eventloop; /** * Create instance */ -bar::make_type bar::make(loop& loop, bool only_initialize_values) { +bar::make_type bar::make(loop& loop, const config& config, bool only_initialize_values) { auto action_ctxt = make_unique(); // clang-format off return std::make_unique( connection::make(), signal_emitter::make(), - config::make(), + config, logger::make(), loop, - screen::make(), + screen::make(config), tags::dispatch::make(*action_ctxt), std::move(action_ctxt), only_initialize_values); @@ -889,7 +889,7 @@ void bar::handle(const evt::configure_notify& evt) { void bar::start(const string& tray_module_name) { m_log.trace("bar: Create renderer"); - m_renderer = renderer::make(m_opts, *m_action_ctxt); + m_renderer = renderer::make(m_opts, *m_action_ctxt, m_conf); m_opts.x_data.window = m_renderer->window(); m_opts.x_data.visual = m_renderer->visual(); @@ -918,7 +918,7 @@ void bar::start(const string& tray_module_name) { m_renderer->end(); m_log.trace("bar: Setup tray manager"); - m_tray->setup(tray_module_name); + m_tray->setup(m_conf, tray_module_name); if (m_tray->settings().tray_position == legacy_tray::tray_postition::MODULE || m_tray->settings().tray_position == legacy_tray::tray_postition::NONE) { diff --git a/src/components/config.cpp b/src/components/config.cpp index 9d5e37ec..be249c4c 100644 --- a/src/components/config.cpp +++ b/src/components/config.cpp @@ -16,13 +16,6 @@ POLYBAR_NS namespace chrono = std::chrono; -/** - * Create instance - */ -config::make_type config::make(string path, string bar) { - return *factory_util::singleton>(logger::make(), move(path), move(bar)); -} - /** * Get path of loaded file */ @@ -63,24 +56,20 @@ file_list config::get_included_files() const { return m_included; } -void config::ignore_key(const string& section, const string& key) const { - if (has(section, key)) { - m_log.warn( - "The config parameter '%s.%s' is deprecated, it will be removed in the future. Please remove it from your " - "config", - section, key); - } -} - /** * Print a deprecation warning if the given parameter is set */ void config::warn_deprecated(const string& section, const string& key, string replacement) const { - try { - auto value = get(section, key); - m_log.warn( - "The config parameter `%s.%s` is deprecated, use `%s.%s` instead.", section, key, section, move(replacement)); - } catch (const key_error& err) { + if (has(section, key)) { + if (replacement.empty()) { + m_log.warn( + "The config parameter '%s.%s' is deprecated, it will be removed in the future. Please remove it from your " + "config", + section, key); + } else { + m_log.warn( + "The config parameter `%s.%s` is deprecated, use `%s.%s` instead.", section, key, section, move(replacement)); + } } } diff --git a/src/components/config_parser.cpp b/src/components/config_parser.cpp index 6403bb1a..c34759af 100644 --- a/src/components/config_parser.cpp +++ b/src/components/config_parser.cpp @@ -11,12 +11,12 @@ POLYBAR_NS config_parser::config_parser(const logger& logger, string&& file) - : m_log(logger), m_config(file_util::expand(file)) {} + : m_log(logger), m_config_file(file_util::expand(file)) {} -config::make_type config_parser::parse(string barname) { - m_log.notice("Parsing config file: %s", m_config); +config config_parser::parse(string barname) { + m_log.notice("Parsing config file: %s", m_config_file); - parse_file(m_config, {}); + parse_file(m_config_file, {}); sectionmap_t sections = create_sectionmap(); @@ -45,18 +45,15 @@ config::make_type config_parser::parse(string barname) { * second element onwards for the included list */ file_list included(m_files.begin() + 1, m_files.end()); - config::make_type result = config::make(m_config, barname); + config conf(m_log, move(m_config_file), move(barname)); - // Cast to non-const to set sections, included and xrm - config& m_conf = const_cast(result); - - m_conf.set_sections(move(sections)); - m_conf.set_included(move(included)); + conf.set_sections(move(sections)); + conf.set_included(move(included)); if (use_xrm) { - m_conf.use_xrm(); + conf.use_xrm(); } - return result; + return conf; } sectionmap_t config_parser::create_sectionmap() { diff --git a/src/components/controller.cpp b/src/components/controller.cpp index 55f66ab3..5548d3de 100644 --- a/src/components/controller.cpp +++ b/src/components/controller.cpp @@ -31,9 +31,9 @@ using namespace modules; /** * Build controller instance */ -controller::make_type controller::make(bool has_ipc, loop& loop) { +controller::make_type controller::make(bool has_ipc, loop& loop, const config& config) { return std::make_unique( - connection::make(), signal_emitter::make(), logger::make(), config::make(), has_ipc, loop); + connection::make(), signal_emitter::make(), logger::make(), config, has_ipc, loop); } /** @@ -46,13 +46,13 @@ controller::controller( , m_log(logger) , m_conf(config) , m_loop(loop) - , m_bar(bar::make(m_loop)) + , m_bar(bar::make(m_loop, config)) , m_has_ipc(has_ipc) { - m_conf.ignore_key("settings", "throttle-input-for"); - m_conf.ignore_key("settings", "throttle-output"); - m_conf.ignore_key("settings", "throttle-output-for"); - m_conf.ignore_key("settings", "eventqueue-swallow"); - m_conf.ignore_key("settings", "eventqueue-swallow-time"); + m_conf.warn_deprecated("settings", "throttle-input-for"); + m_conf.warn_deprecated("settings", "throttle-output"); + m_conf.warn_deprecated("settings", "throttle-output-for"); + m_conf.warn_deprecated("settings", "eventqueue-swallow"); + m_conf.warn_deprecated("settings", "eventqueue-swallow-time"); m_log.trace("controller: Setup user-defined modules"); size_t created_modules{0}; @@ -630,7 +630,7 @@ size_t controller::setup_modules(alignment align) { } m_log.notice("Loading module '%s' of type '%s'", module_name, type); - module_t module = modules::make_module(move(type), m_bar->settings(), module_name, m_log); + module_t module = modules::make_module(move(type), m_bar->settings(), module_name, m_log, m_conf); m_modules.push_back(module); m_blocks[align].push_back(module); diff --git a/src/components/renderer.cpp b/src/components/renderer.cpp index fa0f8ffc..d2cf34f8 100644 --- a/src/components/renderer.cpp +++ b/src/components/renderer.cpp @@ -21,12 +21,12 @@ static constexpr double BLOCK_GAP{20.0}; /** * Create instance */ -renderer::make_type renderer::make(const bar_settings& bar, tags::action_context& action_ctxt) { +renderer::make_type renderer::make(const bar_settings& bar, tags::action_context& action_ctxt, const config& conf) { // clang-format off return std::make_unique( connection::make(), signal_emitter::make(), - config::make(), + conf, logger::make(), forward(bar), background_manager::make(), diff --git a/src/components/screen.cpp b/src/components/screen.cpp index 756afba9..ac39f6db 100644 --- a/src/components/screen.cpp +++ b/src/components/screen.cpp @@ -22,8 +22,8 @@ using namespace signals::eventqueue; /** * Create instance */ -screen::make_type screen::make() { - return std::make_unique(connection::make(), signal_emitter::make(), logger::make(), config::make()); +screen::make_type screen::make(const config& config) { + return std::make_unique(connection::make(), signal_emitter::make(), logger::make(), config); } /** diff --git a/src/main.cpp b/src/main.cpp index 0dad2191..55f28c21 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -128,7 +128,7 @@ int main(int argc, char** argv) { } config_parser parser{logger, move(confpath)}; - config::make_type conf = parser.parse(move(barname)); + config conf = parser.parse(move(barname)); //================================================== // Dump requested data @@ -138,7 +138,7 @@ int main(int argc, char** argv) { return EXIT_SUCCESS; } if (cli->has("print-wmname")) { - printf("%s\n", bar::make(loop, true)->settings().wmname.c_str()); + printf("%s\n", bar::make(loop, conf, true)->settings().wmname.c_str()); return EXIT_SUCCESS; } @@ -156,7 +156,7 @@ int main(int argc, char** argv) { } } - auto ctrl = controller::make((bool)ipc, loop); + auto ctrl = controller::make((bool)ipc, loop, conf); if (!ctrl->run(cli->has("stdout"), cli->get("png"), cli->has("reload"))) { reload = true; diff --git a/src/modules/alsa.cpp b/src/modules/alsa.cpp index 21cd4dc3..94ce7a16 100644 --- a/src/modules/alsa.cpp +++ b/src/modules/alsa.cpp @@ -17,7 +17,8 @@ using namespace alsa; namespace modules { template class module; - alsa_module::alsa_module(const bar_settings& bar, string name_) : event_module(bar, move(name_)) { + alsa_module::alsa_module(const bar_settings& bar, string name_, const config& config) + : event_module(bar, move(name_), config) { if (m_handle_events) { m_router->register_action(EVENT_DEC, [this]() { action_dec(); }); m_router->register_action(EVENT_INC, [this]() { action_inc(); }); diff --git a/src/modules/backlight.cpp b/src/modules/backlight.cpp index abdcd8e4..e65e061b 100644 --- a/src/modules/backlight.cpp +++ b/src/modules/backlight.cpp @@ -23,8 +23,8 @@ namespace modules { return std::strtof(file_util::contents(m_path).c_str(), nullptr); } - backlight_module::backlight_module(const bar_settings& bar, string name_) - : inotify_module(bar, move(name_)) { + backlight_module::backlight_module(const bar_settings& bar, string name_, const config& config) + : inotify_module(bar, move(name_), config) { m_router->register_action(EVENT_DEC, [this]() { action_dec(); }); m_router->register_action(EVENT_INC, [this]() { action_inc(); }); auto card = m_conf.get(name(), "card", ""s); diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp index 2c262287..4d966adc 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -23,8 +23,8 @@ namespace modules { /** * Bootstrap module by setting up required components */ - battery_module::battery_module(const bar_settings& bar, string name_) - : inotify_module(bar, move(name_)) { + battery_module::battery_module(const bar_settings& bar, string name_, const config& config) + : inotify_module(bar, move(name_), config) { // Load configuration values m_fullat = std::min(m_conf.get(name(), "full-at", m_fullat), 100); m_lowat = std::max(m_conf.get(name(), "low-at", m_lowat), 0); diff --git a/src/modules/bspwm.cpp b/src/modules/bspwm.cpp index d3d6e889..65beec12 100644 --- a/src/modules/bspwm.cpp +++ b/src/modules/bspwm.cpp @@ -39,7 +39,8 @@ namespace { namespace modules { template class module; - bspwm_module::bspwm_module(const bar_settings& bar, string name_) : event_module(bar, move(name_)) { + bspwm_module::bspwm_module(const bar_settings& bar, string name_, const config& config) + : event_module(bar, move(name_), config) { m_router->register_action_with_data(EVENT_FOCUS, [this](const std::string& data) { action_focus(data); }); m_router->register_action(EVENT_NEXT, [this]() { action_next(); }); m_router->register_action(EVENT_PREV, [this]() { action_prev(); }); diff --git a/src/modules/counter.cpp b/src/modules/counter.cpp index 3abd5e40..92af5823 100644 --- a/src/modules/counter.cpp +++ b/src/modules/counter.cpp @@ -7,8 +7,8 @@ POLYBAR_NS namespace modules { template class module; - counter_module::counter_module(const bar_settings& bar, string name_) - : timer_module(bar, move(name_)) { + counter_module::counter_module(const bar_settings& bar, string name_, const config& config) + : timer_module(bar, move(name_), config) { set_interval(1s); m_formatter->add(DEFAULT_FORMAT, TAG_COUNTER, {TAG_COUNTER}); } diff --git a/src/modules/cpu.cpp b/src/modules/cpu.cpp index 527f27fb..0e9502da 100644 --- a/src/modules/cpu.cpp +++ b/src/modules/cpu.cpp @@ -14,7 +14,8 @@ POLYBAR_NS namespace modules { template class module; - cpu_module::cpu_module(const bar_settings& bar, string name_) : timer_module(bar, move(name_)) { + cpu_module::cpu_module(const bar_settings& bar, string name_, const config& config) + : timer_module(bar, move(name_), config) { set_interval(1s); m_totalwarn = m_conf.get(name(), "warn-percentage", m_totalwarn); m_ramp_padding = m_conf.get(name(), "ramp-coreload-spacing", m_ramp_padding); diff --git a/src/modules/date.cpp b/src/modules/date.cpp index 7d243195..6e86bdfb 100644 --- a/src/modules/date.cpp +++ b/src/modules/date.cpp @@ -8,7 +8,8 @@ POLYBAR_NS namespace modules { template class module; - date_module::date_module(const bar_settings& bar, string name_) : timer_module(bar, move(name_)) { + date_module::date_module(const bar_settings& bar, string name_, const config& config) + : timer_module(bar, move(name_), config) { if (!m_bar.locale.empty()) { datetime_stream.imbue(std::locale(m_bar.locale.c_str())); } diff --git a/src/modules/fs.cpp b/src/modules/fs.cpp index ad1ac250..2a9ca8c2 100644 --- a/src/modules/fs.cpp +++ b/src/modules/fs.cpp @@ -26,7 +26,8 @@ namespace modules { * Bootstrap the module by reading config values and * setting up required components */ - fs_module::fs_module(const bar_settings& bar, string name_) : timer_module(bar, move(name_)) { + fs_module::fs_module(const bar_settings& bar, string name_, const config& config) + : timer_module(bar, move(name_), config) { m_mountpoints = m_conf.get_list(name(), "mount", {}); if (m_mountpoints.empty()) { m_log.info("%s: No mountpoints specified, using fallback \"/\"", name()); diff --git a/src/modules/github.cpp b/src/modules/github.cpp index 32b5a08b..bf7a8239 100644 --- a/src/modules/github.cpp +++ b/src/modules/github.cpp @@ -14,7 +14,8 @@ namespace modules { /** * Construct module */ - github_module::github_module(const bar_settings& bar, string name_) : timer_module(bar, move(name_)) { + github_module::github_module(const bar_settings& bar, string name_, const config& config) + : timer_module(bar, move(name_), config) { m_accesstoken = m_conf.get(name(), "token"); m_user = m_conf.get(name(), "user", ""s); m_api_url = m_conf.get(name(), "api-url", "https://api.github.com/"s); diff --git a/src/modules/i3.cpp b/src/modules/i3.cpp index d2bc0e86..15185477 100644 --- a/src/modules/i3.cpp +++ b/src/modules/i3.cpp @@ -12,7 +12,8 @@ POLYBAR_NS namespace modules { template class module; - i3_module::i3_module(const bar_settings& bar, string name_) : event_module(bar, move(name_)) { + i3_module::i3_module(const bar_settings& bar, string name_, const config& conf) + : event_module(bar, move(name_), conf) { m_router->register_action_with_data(EVENT_FOCUS, [this](const std::string& data) { action_focus(data); }); m_router->register_action(EVENT_NEXT, [this]() { action_next(); }); m_router->register_action(EVENT_PREV, [this]() { action_prev(); }); diff --git a/src/modules/ipc.cpp b/src/modules/ipc.cpp index aaaac0ff..9e337020 100644 --- a/src/modules/ipc.cpp +++ b/src/modules/ipc.cpp @@ -14,7 +14,8 @@ namespace modules { * Load user-defined ipc hooks and * create formatting tags */ - ipc_module::ipc_module(const bar_settings& bar, string name_) : module(bar, move(name_)) { + ipc_module::ipc_module(const bar_settings& bar, string name_, const config& config) + : module(bar, move(name_), config) { m_router->register_action_with_data(EVENT_SEND, [this](const std::string& data) { action_send(data); }); m_router->register_action_with_data(EVENT_HOOK, [this](const std::string& data) { action_hook(data); }); m_router->register_action(EVENT_NEXT, [this]() { action_next(); }); diff --git a/src/modules/memory.cpp b/src/modules/memory.cpp index eb36e5dc..5989f6f5 100644 --- a/src/modules/memory.cpp +++ b/src/modules/memory.cpp @@ -15,7 +15,8 @@ POLYBAR_NS namespace modules { template class module; - memory_module::memory_module(const bar_settings& bar, string name_) : timer_module(bar, move(name_)) { + memory_module::memory_module(const bar_settings& bar, string name_, const config& config) + : timer_module(bar, move(name_), config) { set_interval(1s); m_perc_memused_warn = m_conf.get(name(), "warn-percentage", 90); diff --git a/src/modules/menu.cpp b/src/modules/menu.cpp index e8aa2c8d..afd36aed 100644 --- a/src/modules/menu.cpp +++ b/src/modules/menu.cpp @@ -11,7 +11,8 @@ POLYBAR_NS namespace modules { template class module; - menu_module::menu_module(const bar_settings& bar, string name_) : static_module(bar, move(name_)) { + menu_module::menu_module(const bar_settings& bar, string name_, const config& config) + : static_module(bar, move(name_), config) { m_expand_right = m_conf.get(name(), "expand-right", m_expand_right); m_router->register_action_with_data(EVENT_OPEN, [this](const std::string& data) { action_open(data); }); diff --git a/src/modules/meta/factory.cpp b/src/modules/meta/factory.cpp index 07a52710..203475fc 100644 --- a/src/modules/meta/factory.cpp +++ b/src/modules/meta/factory.cpp @@ -9,7 +9,7 @@ namespace modules { /** * Function pointer for creating a module. */ - using factory_fun = module_t (*)(const bar_settings&, string&&); + using factory_fun = module_t (*)(const bar_settings&, string&&, const config&); using factory_map = map; /** @@ -19,8 +19,8 @@ namespace modules { */ template static constexpr factory_fun get_factory() { - return [](const bar_settings& bar, string&& module_name) -> module_t { - return make_shared(bar, move(module_name)); + return [](const bar_settings& bar, string&& module_name, const config& config) -> module_t { + return make_shared(bar, move(module_name), config); }; } @@ -66,7 +66,7 @@ namespace modules { map_entry(), }; - module_t make_module(string&& type, const bar_settings& bar, string module_name, const logger& log) { + module_t make_module(string&& type, const bar_settings& bar, string module_name, const logger& log, const config& config) { string actual_type = type; if (type == "internal/volume") { @@ -76,7 +76,7 @@ namespace modules { auto it = factories.find(actual_type); if (it != factories.end()) { - return it->second(bar, std::move(module_name)); + return it->second(bar, std::move(module_name), config); } else { throw application_error("Unknown module: " + type); } diff --git a/src/modules/mpd.cpp b/src/modules/mpd.cpp index 56c9c361..2baa9942 100644 --- a/src/modules/mpd.cpp +++ b/src/modules/mpd.cpp @@ -12,7 +12,8 @@ POLYBAR_NS namespace modules { template class module; - mpd_module::mpd_module(const bar_settings& bar, string name_) : event_module(bar, move(name_)) { + mpd_module::mpd_module(const bar_settings& bar, string name_, const config& config) + : event_module(bar, move(name_), config) { m_router->register_action(EVENT_PLAY, [this]() { action_play(); }); m_router->register_action(EVENT_PAUSE, [this]() { action_pause(); }); m_router->register_action(EVENT_STOP, [this]() { action_stop(); }); diff --git a/src/modules/network.cpp b/src/modules/network.cpp index f8ecb490..ea7f03be 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -10,8 +10,8 @@ POLYBAR_NS namespace modules { template class module; - network_module::network_module(const bar_settings& bar, string name_) - : timer_module(bar, move(name_)) { + network_module::network_module(const bar_settings& bar, string name_, const config& config) + : timer_module(bar, move(name_), config) { // Load configuration values m_interface = m_conf.get(name(), "interface", m_interface); diff --git a/src/modules/pulseaudio.cpp b/src/modules/pulseaudio.cpp index f240d2ed..a5d49bd3 100644 --- a/src/modules/pulseaudio.cpp +++ b/src/modules/pulseaudio.cpp @@ -13,8 +13,8 @@ POLYBAR_NS namespace modules { template class module; - pulseaudio_module::pulseaudio_module(const bar_settings& bar, string name_) - : event_module(bar, move(name_)) { + pulseaudio_module::pulseaudio_module(const bar_settings& bar, string name_, const config& config) + : event_module(bar, move(name_), config) { if (m_handle_events) { m_router->register_action(EVENT_DEC, [this]() { action_dec(); }); m_router->register_action(EVENT_INC, [this]() { action_inc(); }); diff --git a/src/modules/script.cpp b/src/modules/script.cpp index 4ff9bebf..abd4c0e4 100644 --- a/src/modules/script.cpp +++ b/src/modules/script.cpp @@ -6,8 +6,8 @@ POLYBAR_NS namespace modules { - script_module::script_module(const bar_settings& bar, string name_) - : module(bar, move(name_)) + script_module::script_module(const bar_settings& bar, string name_, const config& config) + : module(bar, move(name_), config) , m_tail(m_conf.get(name(), "tail", false)) , m_interval_success(m_conf.get(name(), "interval", m_tail ? 0s : 5s)) , m_interval_fail(m_conf.get(name(), "interval-fail", m_interval_success)) diff --git a/src/modules/temperature.cpp b/src/modules/temperature.cpp index 98e0f38e..b038e5c4 100644 --- a/src/modules/temperature.cpp +++ b/src/modules/temperature.cpp @@ -13,8 +13,8 @@ POLYBAR_NS namespace modules { template class module; - temperature_module::temperature_module(const bar_settings& bar, string name_) - : timer_module(bar, move(name_)) { + temperature_module::temperature_module(const bar_settings& bar, string name_, const config& config) + : timer_module(bar, move(name_), config) { m_zone = m_conf.get(name(), "thermal-zone", 0); m_zone_type = m_conf.get(name(), "zone-type", ""s); m_path = m_conf.get(name(), "hwmon-path", ""s); diff --git a/src/modules/text.cpp b/src/modules/text.cpp index 3f84c603..e04172a7 100644 --- a/src/modules/text.cpp +++ b/src/modules/text.cpp @@ -8,7 +8,8 @@ POLYBAR_NS namespace modules { template class module; - text_module::text_module(const bar_settings& bar, string name_) : static_module(bar, move(name_)) { + text_module::text_module(const bar_settings& bar, string name_, const config& config) + : static_module(bar, move(name_), config) { m_formatter->add(DEFAULT_FORMAT, TAG_LABEL, {TAG_LABEL}); m_formatter->add_optional("content", {}); diff --git a/src/modules/tray.cpp b/src/modules/tray.cpp index a09ef28d..23c73448 100644 --- a/src/modules/tray.cpp +++ b/src/modules/tray.cpp @@ -7,8 +7,8 @@ POLYBAR_NS namespace modules { template class module; - tray_module::tray_module(const bar_settings& bar_settings, string name_) - : static_module(bar_settings, move(name_)) + tray_module::tray_module(const bar_settings& bar_settings, string name_, const config& config) + : static_module(bar_settings, move(name_), config) , m_tray(connection::make(), signal_emitter::make(), m_log, bar_settings, [&] { this->broadcast(); }) { m_formatter->add(DEFAULT_FORMAT, TAG_TRAY, {TAG_TRAY}); } diff --git a/src/modules/xbacklight.cpp b/src/modules/xbacklight.cpp index 85d2a3d0..0b65d9b0 100644 --- a/src/modules/xbacklight.cpp +++ b/src/modules/xbacklight.cpp @@ -16,8 +16,8 @@ namespace modules { /** * Construct module */ - xbacklight_module::xbacklight_module(const bar_settings& bar, string name_) - : static_module(bar, move(name_)), m_connection(connection::make()) { + xbacklight_module::xbacklight_module(const bar_settings& bar, string name_, const config& config) + : static_module(bar, move(name_), config), m_connection(connection::make()) { m_router->register_action(EVENT_INC, [this]() { action_inc(); }); m_router->register_action(EVENT_DEC, [this]() { action_dec(); }); diff --git a/src/modules/xkeyboard.cpp b/src/modules/xkeyboard.cpp index 53920640..28ac9c4a 100644 --- a/src/modules/xkeyboard.cpp +++ b/src/modules/xkeyboard.cpp @@ -22,8 +22,8 @@ namespace modules { /** * Construct module */ - xkeyboard_module::xkeyboard_module(const bar_settings& bar, string name_) - : static_module(bar, move(name_)), m_connection(connection::make()) { + xkeyboard_module::xkeyboard_module(const bar_settings& bar, string name_, const config& config) + : static_module(bar, move(name_), config), m_connection(connection::make()) { m_router->register_action(EVENT_SWITCH, [this]() { action_switch(); }); // Setup extension diff --git a/src/modules/xwindow.cpp b/src/modules/xwindow.cpp index 32867a82..e8cef201 100644 --- a/src/modules/xwindow.cpp +++ b/src/modules/xwindow.cpp @@ -69,8 +69,8 @@ namespace modules { /** * Construct module */ - xwindow_module::xwindow_module(const bar_settings& bar, string name_) - : static_module(bar, move(name_)), m_connection(connection::make()) { + xwindow_module::xwindow_module(const bar_settings& bar, string name_, const config& config) + : static_module(bar, move(name_), config), m_connection(connection::make()) { // Initialize ewmh atoms ewmh_util::initialize(); diff --git a/src/modules/xworkspaces.cpp b/src/modules/xworkspaces.cpp index f14ce1d3..85037835 100644 --- a/src/modules/xworkspaces.cpp +++ b/src/modules/xworkspaces.cpp @@ -27,8 +27,8 @@ namespace modules { /** * Construct module */ - xworkspaces_module::xworkspaces_module(const bar_settings& bar, string name_) - : static_module(bar, move(name_)) + xworkspaces_module::xworkspaces_module(const bar_settings& bar, string name_, const config& config) + : static_module(bar, move(name_), config) , m_connection(connection::make()) , m_ewmh(ewmh_util::initialize()) { m_router->register_action_with_data(EVENT_FOCUS, [this](const std::string& data) { action_focus(data); }); diff --git a/src/x11/legacy_tray_manager.cpp b/src/x11/legacy_tray_manager.cpp index 14888270..db7e6ebe 100644 --- a/src/x11/legacy_tray_manager.cpp +++ b/src/x11/legacy_tray_manager.cpp @@ -8,7 +8,6 @@ #include "cairo/context.hpp" #include "cairo/surface.hpp" -#include "components/config.hpp" #include "errors.hpp" #include "events/signal.hpp" #include "utils/color.hpp" @@ -55,8 +54,7 @@ tray_manager::~tray_manager() { deactivate(); } -void tray_manager::setup(const string& tray_module_name) { - const config& conf = config::make(); +void tray_manager::setup(const config& conf, const string& tray_module_name) { auto bs = conf.section(); string position = conf.get(bs, "tray-position", "none"s);