config: Print deprecation warnings

This commit is contained in:
Michael Carlberg 2016-11-22 03:01:50 +01:00
parent 733341d62b
commit 09e0ea1932
5 changed files with 19 additions and 2 deletions

View File

@ -30,6 +30,7 @@ class config {
string bar_section() const;
vector<string> 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

View File

@ -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;

View File

@ -106,6 +106,9 @@ void bar::bootstrap(bool nodraw) {
auto linecolor = color::parse(m_conf.get<string>(bs, "linecolor", "#f00"));
auto lineheight = m_conf.get<int>(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<int16_t>(bs, "overline-size", lineheight);
m_opts.overline.color = color::parse(m_conf.get<string>(bs, "overline-color"));

View File

@ -1,8 +1,8 @@
#include <algorithm>
#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<string>(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

View File

@ -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<double>(m_conf.get<float>(name(), "interval", 1));
// Add formats