From 09e0ea19320ecdee048949afed82d82b84152a8b Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Tue, 22 Nov 2016 03:01:50 +0100 Subject: [PATCH] config: Print deprecation warnings --- include/components/config.hpp | 1 + include/components/types.hpp | 2 +- src/components/bar.cpp | 3 +++ src/components/config.cpp | 13 ++++++++++++- src/modules/network.cpp | 2 ++ 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/components/config.hpp b/include/components/config.hpp index 41696670..d6a6e998 100644 --- a/include/components/config.hpp +++ b/include/components/config.hpp @@ -30,6 +30,7 @@ class config { string bar_section() const; vector defined_bars() const; string build_path(const string& section, const string& key) const; + void warn_deprecated(string section, string key, string replacement) const; /** * Get parameter for the current bar by name diff --git a/include/components/types.hpp b/include/components/types.hpp index 3aaf38e4..6d6f3aa3 100644 --- a/include/components/types.hpp +++ b/include/components/types.hpp @@ -74,7 +74,7 @@ struct bar_settings { edge_values strut{0, 0, 0, 0}; uint32_t background{0xFFFFFFFF}; - uint32_t foreground{0xFF0000FF}; + uint32_t foreground{0xFF000000}; line_settings underline; line_settings overline; diff --git a/src/components/bar.cpp b/src/components/bar.cpp index 8e6fd086..e550ec14 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -106,6 +106,9 @@ void bar::bootstrap(bool nodraw) { auto linecolor = color::parse(m_conf.get(bs, "linecolor", "#f00")); auto lineheight = m_conf.get(bs, "lineheight", 0); + m_conf.warn_deprecated(bs, "linecolor", "{underline,overline}-color"); + m_conf.warn_deprecated(bs, "lineheight", "{underline,overline}-size"); + try { m_opts.overline.size = m_conf.get(bs, "overline-size", lineheight); m_opts.overline.color = color::parse(m_conf.get(bs, "overline-color")); diff --git a/src/components/config.cpp b/src/components/config.cpp index fa0c79d2..c8bc86a8 100644 --- a/src/components/config.cpp +++ b/src/components/config.cpp @@ -1,8 +1,8 @@ #include #include "components/config.hpp" -#include "utils/file.hpp" #include "utils/env.hpp" +#include "utils/file.hpp" POLYBAR_NS @@ -72,4 +72,15 @@ string config::build_path(const string& section, const string& key) const { return section + "." + key; } +/** + * Print a deprecation warning if the given parameter is set + */ +void config::warn_deprecated(string section, string key, string replacement) const { + try { + auto value = get(section, key); + m_logger.warn("The config parameter `%s.%s` is deprecated, use `%s` instead.", section, key, replacement); + } catch (const key_error& err) { + } +} + POLYBAR_NS_END diff --git a/src/modules/network.cpp b/src/modules/network.cpp index d0ac21c1..6d06454d 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -20,6 +20,8 @@ namespace modules { GET_CONFIG_VALUE(name(), m_udspeed_minwidth, "udspeed-minwidth"); GET_CONFIG_VALUE(name(), m_accumulate, "accumulate-stats"); + m_conf.warn_deprecated(name(), "udspeed-minwidth", "%downspeed:min:max% and %upspeed:min:max%"); + m_interval = chrono::duration(m_conf.get(name(), "interval", 1)); // Add formats