config: Print deprecation warnings
This commit is contained in:
parent
733341d62b
commit
09e0ea1932
@ -30,6 +30,7 @@ class config {
|
|||||||
string bar_section() const;
|
string bar_section() const;
|
||||||
vector<string> defined_bars() const;
|
vector<string> defined_bars() const;
|
||||||
string build_path(const string& section, const string& key) 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
|
* Get parameter for the current bar by name
|
||||||
|
@ -74,7 +74,7 @@ struct bar_settings {
|
|||||||
edge_values strut{0, 0, 0, 0};
|
edge_values strut{0, 0, 0, 0};
|
||||||
|
|
||||||
uint32_t background{0xFFFFFFFF};
|
uint32_t background{0xFFFFFFFF};
|
||||||
uint32_t foreground{0xFF0000FF};
|
uint32_t foreground{0xFF000000};
|
||||||
|
|
||||||
line_settings underline;
|
line_settings underline;
|
||||||
line_settings overline;
|
line_settings overline;
|
||||||
|
@ -106,6 +106,9 @@ void bar::bootstrap(bool nodraw) {
|
|||||||
auto linecolor = color::parse(m_conf.get<string>(bs, "linecolor", "#f00"));
|
auto linecolor = color::parse(m_conf.get<string>(bs, "linecolor", "#f00"));
|
||||||
auto lineheight = m_conf.get<int>(bs, "lineheight", 0);
|
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 {
|
try {
|
||||||
m_opts.overline.size = m_conf.get<int16_t>(bs, "overline-size", lineheight);
|
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"));
|
m_opts.overline.color = color::parse(m_conf.get<string>(bs, "overline-color"));
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "components/config.hpp"
|
#include "components/config.hpp"
|
||||||
#include "utils/file.hpp"
|
|
||||||
#include "utils/env.hpp"
|
#include "utils/env.hpp"
|
||||||
|
#include "utils/file.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
@ -72,4 +72,15 @@ string config::build_path(const string& section, const string& key) const {
|
|||||||
return section + "." + key;
|
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
|
POLYBAR_NS_END
|
||||||
|
@ -20,6 +20,8 @@ namespace modules {
|
|||||||
GET_CONFIG_VALUE(name(), m_udspeed_minwidth, "udspeed-minwidth");
|
GET_CONFIG_VALUE(name(), m_udspeed_minwidth, "udspeed-minwidth");
|
||||||
GET_CONFIG_VALUE(name(), m_accumulate, "accumulate-stats");
|
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));
|
m_interval = chrono::duration<double>(m_conf.get<float>(name(), "interval", 1));
|
||||||
|
|
||||||
// Add formats
|
// Add formats
|
||||||
|
Loading…
Reference in New Issue
Block a user