mirror of
https://github.com/polybar/polybar.git
synced 2024-11-25 13:55:47 -05:00
refactor(config): Deduce return type from default value
This commit is contained in:
parent
a0f1d97c2b
commit
78bb3695e6
33 changed files with 184 additions and 196 deletions
|
@ -48,6 +48,8 @@ using std::array;
|
|||
using std::vector;
|
||||
using std::to_string;
|
||||
|
||||
using namespace std::string_literals;
|
||||
|
||||
constexpr size_t operator"" _z(unsigned long long n) {
|
||||
return n;
|
||||
}
|
||||
|
|
|
@ -42,11 +42,10 @@ class bar : public xpp::event::sink<evt::button_press, evt::expose, evt::propert
|
|||
unique_ptr<tray_manager>&&, unique_ptr<parser>&&, unique_ptr<taskqueue>&&, bool only_initialize_values);
|
||||
~bar();
|
||||
|
||||
void parse(string&& data) const;
|
||||
void parse(const string& data, bool force = false);
|
||||
|
||||
const bar_settings settings() const;
|
||||
|
||||
void parse(string&& data);
|
||||
|
||||
protected:
|
||||
void restack_window();
|
||||
void reconfigure_pos();
|
||||
|
|
|
@ -11,9 +11,6 @@
|
|||
|
||||
POLYBAR_NS
|
||||
|
||||
#define GET_CONFIG_VALUE(section, var, name) var = m_conf.get<decltype(var)>(section, name, var)
|
||||
#define REQ_CONFIG_VALUE(section, var, name) var = m_conf.get<decltype(var)>(section, name)
|
||||
|
||||
DEFINE_ERROR(value_error);
|
||||
DEFINE_ERROR(key_error);
|
||||
|
||||
|
@ -43,7 +40,7 @@ class config {
|
|||
/**
|
||||
* Get parameter for the current bar by name
|
||||
*/
|
||||
template <typename T>
|
||||
template <typename T = string>
|
||||
T get(const string& key) const {
|
||||
return get<T>(section(), key);
|
||||
}
|
||||
|
@ -51,7 +48,7 @@ class config {
|
|||
/**
|
||||
* Get value of a variable by section and parameter name
|
||||
*/
|
||||
template <typename T>
|
||||
template <typename T = string>
|
||||
T get(const string& section, const string& key) const {
|
||||
auto it = m_sections.find(section);
|
||||
if (it == m_sections.end() || it->second.find(key) == it->second.end()) {
|
||||
|
@ -64,7 +61,7 @@ class config {
|
|||
* Get value of a variable by section and parameter name
|
||||
* with a default value in case the parameter isn't defined
|
||||
*/
|
||||
template <typename T>
|
||||
template <typename T = string>
|
||||
T get(const string& section, const string& key, const T& default_value) const {
|
||||
try {
|
||||
string string_value{get<string>(section, key)};
|
||||
|
@ -78,7 +75,7 @@ class config {
|
|||
/**
|
||||
* Get list of values for the current bar by name
|
||||
*/
|
||||
template <typename T>
|
||||
template <typename T = string>
|
||||
vector<T> get_list(const string& key) const {
|
||||
return get_list<T>(section(), key);
|
||||
}
|
||||
|
@ -86,7 +83,7 @@ class config {
|
|||
/**
|
||||
* Get list of values by section and parameter name
|
||||
*/
|
||||
template <typename T>
|
||||
template <typename T = string>
|
||||
vector<T> get_list(const string& section, const string& key) const {
|
||||
vector<T> results;
|
||||
|
||||
|
@ -116,7 +113,7 @@ class config {
|
|||
* Get list of values by section and parameter name
|
||||
* with a default list in case the list isn't defined
|
||||
*/
|
||||
template <typename T>
|
||||
template <typename T = string>
|
||||
vector<T> get_list(const string& section, const string& key, const vector<T>& default_value) const {
|
||||
vector<T> results;
|
||||
|
||||
|
@ -148,7 +145,7 @@ class config {
|
|||
* warning message. If it fails load the value using the new key and given
|
||||
* fallback value
|
||||
*/
|
||||
template <typename T>
|
||||
template <typename T = string>
|
||||
T deprecated(const string& section, const string& old, const string& newkey, const T& fallback) const {
|
||||
try {
|
||||
T value{get<T>(section, old)};
|
||||
|
@ -162,7 +159,7 @@ class config {
|
|||
/**
|
||||
* @see deprecated<T>
|
||||
*/
|
||||
template <typename T>
|
||||
template <typename T = string>
|
||||
T deprecated_list(const string& section, const string& old, const string& newkey, const vector<T>& fallback) const {
|
||||
try {
|
||||
vector<T> value{get_list<T>(section, old)};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <xcb/xcb_icccm.h>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#include "components/bar.hpp"
|
||||
#include "components/config.hpp"
|
||||
|
@ -69,9 +68,9 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const
|
|||
string bs{m_conf.section()};
|
||||
|
||||
// Get available RandR outputs
|
||||
auto monitor_name = m_conf.get<string>(bs, "monitor", "");
|
||||
auto monitor_name_fallback = m_conf.get<string>(bs, "monitor-fallback", "");
|
||||
auto monitor_strictmode = m_conf.get<bool>(bs, "monitor-strict", false);
|
||||
auto monitor_name = m_conf.get(bs, "monitor", ""s);
|
||||
auto monitor_name_fallback = m_conf.get(bs, "monitor-fallback", ""s);
|
||||
auto monitor_strictmode = m_conf.get(bs, "monitor-strict", false);
|
||||
auto monitors = randr_util::get_monitors(m_connection, m_connection.screen()->root, monitor_strictmode);
|
||||
|
||||
if (monitors.empty()) {
|
||||
|
@ -123,46 +122,44 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const
|
|||
m_opts.override_redirect = m_conf.get<bool>(bs, "dock");
|
||||
m_conf.warn_deprecated(bs, "dock", "override-redirect");
|
||||
} catch (const key_error& err) {
|
||||
m_opts.override_redirect = m_conf.get<bool>(bs, "override-redirect", m_opts.override_redirect);
|
||||
m_opts.override_redirect = m_conf.get(bs, "override-redirect", m_opts.override_redirect);
|
||||
}
|
||||
|
||||
m_opts.dimvalue = m_conf.get<double>(bs, "dim-value", 1.0);
|
||||
m_opts.dimvalue = m_conf.get(bs, "dim-value", 1.0);
|
||||
m_opts.dimvalue = math_util::cap(m_opts.dimvalue, 0.0, 1.0);
|
||||
|
||||
// Build WM_NAME
|
||||
m_opts.wmname = m_conf.get<string>(bs, "wm-name", "polybar-" + bs.substr(4) + "_" + m_opts.monitor->name);
|
||||
m_opts.wmname = m_conf.get(bs, "wm-name", "polybar-" + bs.substr(4) + "_" + m_opts.monitor->name);
|
||||
m_opts.wmname = string_util::replace(m_opts.wmname, " ", "-");
|
||||
|
||||
// Load configuration values
|
||||
m_opts.origin = m_conf.get<bool>(bs, "bottom", false) ? edge::BOTTOM : edge::TOP;
|
||||
m_opts.spacing = m_conf.get<decltype(m_opts.spacing)>(bs, "spacing", m_opts.spacing);
|
||||
m_opts.padding.left = m_conf.get<decltype(m_opts.padding.left)>(bs, "padding-left", m_opts.padding.left);
|
||||
m_opts.padding.right = m_conf.get<decltype(m_opts.padding.right)>(bs, "padding-right", m_opts.padding.right);
|
||||
m_opts.module_margin.left =
|
||||
m_conf.get<decltype(m_opts.module_margin.left)>(bs, "module-margin-left", m_opts.module_margin.left);
|
||||
m_opts.module_margin.right =
|
||||
m_conf.get<decltype(m_opts.module_margin.right)>(bs, "module-margin-right", m_opts.module_margin.right);
|
||||
m_opts.separator = string_util::trim(m_conf.get<string>(bs, "separator", ""), '"');
|
||||
m_opts.locale = m_conf.get<string>(bs, "locale", "");
|
||||
m_opts.origin = m_conf.get(bs, "bottom", false) ? edge::BOTTOM : edge::TOP;
|
||||
m_opts.spacing = m_conf.get(bs, "spacing", m_opts.spacing);
|
||||
m_opts.padding.left = m_conf.get(bs, "padding-left", m_opts.padding.left);
|
||||
m_opts.padding.right = m_conf.get(bs, "padding-right", m_opts.padding.right);
|
||||
m_opts.module_margin.left = m_conf.get(bs, "module-margin-left", m_opts.module_margin.left);
|
||||
m_opts.module_margin.right = m_conf.get(bs, "module-margin-right", m_opts.module_margin.right);
|
||||
m_opts.separator = string_util::trim(m_conf.get(bs, "separator", ""s), '"');
|
||||
m_opts.locale = m_conf.get(bs, "locale", ""s);
|
||||
|
||||
if (only_initialize_values) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Load values used to adjust the struts atom
|
||||
m_opts.strut.top = m_conf.get<int>("global/wm", "margin-top", 0);
|
||||
m_opts.strut.bottom = m_conf.get<int>("global/wm", "margin-bottom", 0);
|
||||
m_opts.strut.top = m_conf.get("global/wm", "margin-top", 0);
|
||||
m_opts.strut.bottom = m_conf.get("global/wm", "margin-bottom", 0);
|
||||
|
||||
// Load commands used for fallback click handlers
|
||||
vector<action> actions;
|
||||
actions.emplace_back(action{mousebtn::LEFT, m_conf.get<string>(bs, "click-left", "")});
|
||||
actions.emplace_back(action{mousebtn::MIDDLE, m_conf.get<string>(bs, "click-middle", "")});
|
||||
actions.emplace_back(action{mousebtn::RIGHT, m_conf.get<string>(bs, "click-right", "")});
|
||||
actions.emplace_back(action{mousebtn::SCROLL_UP, m_conf.get<string>(bs, "scroll-up", "")});
|
||||
actions.emplace_back(action{mousebtn::SCROLL_DOWN, m_conf.get<string>(bs, "scroll-down", "")});
|
||||
actions.emplace_back(action{mousebtn::DOUBLE_LEFT, m_conf.get<string>(bs, "double-click-left", "")});
|
||||
actions.emplace_back(action{mousebtn::DOUBLE_MIDDLE, m_conf.get<string>(bs, "double-click-middle", "")});
|
||||
actions.emplace_back(action{mousebtn::DOUBLE_RIGHT, m_conf.get<string>(bs, "double-click-right", "")});
|
||||
actions.emplace_back(action{mousebtn::LEFT, m_conf.get(bs, "click-left", ""s)});
|
||||
actions.emplace_back(action{mousebtn::MIDDLE, m_conf.get(bs, "click-middle", ""s)});
|
||||
actions.emplace_back(action{mousebtn::RIGHT, m_conf.get(bs, "click-right", ""s)});
|
||||
actions.emplace_back(action{mousebtn::SCROLL_UP, m_conf.get(bs, "scroll-up", ""s)});
|
||||
actions.emplace_back(action{mousebtn::SCROLL_DOWN, m_conf.get(bs, "scroll-down", ""s)});
|
||||
actions.emplace_back(action{mousebtn::DOUBLE_LEFT, m_conf.get(bs, "double-click-left", ""s)});
|
||||
actions.emplace_back(action{mousebtn::DOUBLE_MIDDLE, m_conf.get(bs, "double-click-middle", ""s)});
|
||||
actions.emplace_back(action{mousebtn::DOUBLE_RIGHT, m_conf.get(bs, "double-click-right", ""s)});
|
||||
|
||||
for (auto&& act : actions) {
|
||||
if (!act.command.empty()) {
|
||||
|
@ -171,42 +168,42 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const
|
|||
}
|
||||
|
||||
// Load foreground/background
|
||||
m_opts.background = color::parse(m_conf.get<string>(bs, "background", color_util::hex<uint16_t>(m_opts.background)));
|
||||
m_opts.foreground = color::parse(m_conf.get<string>(bs, "foreground", color_util::hex<uint16_t>(m_opts.foreground)));
|
||||
m_opts.background = color::parse(m_conf.get(bs, "background", color_util::hex<uint16_t>(m_opts.background)));
|
||||
m_opts.foreground = color::parse(m_conf.get(bs, "foreground", color_util::hex<uint16_t>(m_opts.foreground)));
|
||||
|
||||
// Load over-/underline color and size (warn about deprecated params if used)
|
||||
m_conf.warn_deprecated(bs, "linecolor", "{underline,overline}-color");
|
||||
m_conf.warn_deprecated(bs, "lineheight", "{underline,overline}-size");
|
||||
|
||||
auto linecolor = color::parse(m_conf.get<string>(bs, "linecolor", "#f00"));
|
||||
auto lineheight = m_conf.get<int>(bs, "lineheight", 0);
|
||||
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", linecolor));
|
||||
m_opts.underline.size = m_conf.get<uint16_t>(bs, "underline-size", lineheight);
|
||||
m_opts.underline.color = color::parse(m_conf.get<string>(bs, "underline-color", linecolor));
|
||||
auto linecolor = color::parse(m_conf.get(bs, "linecolor", "#f00"s));
|
||||
auto lineheight = m_conf.get(bs, "lineheight", 0);
|
||||
m_opts.overline.size = m_conf.get(bs, "overline-size", lineheight);
|
||||
m_opts.overline.color = color::parse(m_conf.get(bs, "overline-color", linecolor));
|
||||
m_opts.underline.size = m_conf.get(bs, "underline-size", lineheight);
|
||||
m_opts.underline.color = color::parse(m_conf.get(bs, "underline-color", linecolor));
|
||||
|
||||
// Load border settings
|
||||
auto bsize = m_conf.get<int>(bs, "border-size", 0);
|
||||
auto bcolor = m_conf.get<string>(bs, "border-color", "#00000000");
|
||||
auto bsize = m_conf.get(bs, "border-size", 0);
|
||||
auto bcolor = m_conf.get(bs, "border-color", "#00000000"s);
|
||||
|
||||
m_opts.borders.emplace(edge::TOP, border_settings{});
|
||||
m_opts.borders[edge::TOP].size = m_conf.get<int>(bs, "border-top", bsize);
|
||||
m_opts.borders[edge::TOP].color = color::parse(m_conf.get<string>(bs, "border-top-color", bcolor));
|
||||
m_opts.borders[edge::TOP].size = m_conf.get(bs, "border-top", bsize);
|
||||
m_opts.borders[edge::TOP].color = color::parse(m_conf.get(bs, "border-top-color", bcolor));
|
||||
m_opts.borders.emplace(edge::BOTTOM, border_settings{});
|
||||
m_opts.borders[edge::BOTTOM].size = m_conf.get<int>(bs, "border-bottom", bsize);
|
||||
m_opts.borders[edge::BOTTOM].color = color::parse(m_conf.get<string>(bs, "border-bottom-color", bcolor));
|
||||
m_opts.borders[edge::BOTTOM].size = m_conf.get(bs, "border-bottom", bsize);
|
||||
m_opts.borders[edge::BOTTOM].color = color::parse(m_conf.get(bs, "border-bottom-color", bcolor));
|
||||
m_opts.borders.emplace(edge::LEFT, border_settings{});
|
||||
m_opts.borders[edge::LEFT].size = m_conf.get<int>(bs, "border-left", bsize);
|
||||
m_opts.borders[edge::LEFT].color = color::parse(m_conf.get<string>(bs, "border-left-color", bcolor));
|
||||
m_opts.borders[edge::LEFT].size = m_conf.get(bs, "border-left", bsize);
|
||||
m_opts.borders[edge::LEFT].color = color::parse(m_conf.get(bs, "border-left-color", bcolor));
|
||||
m_opts.borders.emplace(edge::RIGHT, border_settings{});
|
||||
m_opts.borders[edge::RIGHT].size = m_conf.get<int>(bs, "border-right", bsize);
|
||||
m_opts.borders[edge::RIGHT].color = color::parse(m_conf.get<string>(bs, "border-right-color", bcolor));
|
||||
m_opts.borders[edge::RIGHT].size = m_conf.get(bs, "border-right", bsize);
|
||||
m_opts.borders[edge::RIGHT].color = color::parse(m_conf.get(bs, "border-right-color", bcolor));
|
||||
|
||||
// Load geometry values
|
||||
auto w = m_conf.get<string>(m_conf.section(), "width", "100%");
|
||||
auto h = m_conf.get<string>(m_conf.section(), "height", "24");
|
||||
auto offsetx = m_conf.get<string>(m_conf.section(), "offset-x", "");
|
||||
auto offsety = m_conf.get<string>(m_conf.section(), "offset-y", "");
|
||||
auto w = m_conf.get(m_conf.section(), "width", "100%"s);
|
||||
auto h = m_conf.get(m_conf.section(), "height", "24"s);
|
||||
auto offsetx = m_conf.get(m_conf.section(), "offset-x", ""s);
|
||||
auto offsety = m_conf.get(m_conf.section(), "offset-y", ""s);
|
||||
|
||||
if ((m_opts.size.w = atoi(w.c_str())) && w.find('%') != string::npos) {
|
||||
m_opts.size.w = math_util::percentage_to_value<int>(m_opts.size.w, m_opts.monitor->w);
|
||||
|
@ -251,7 +248,7 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const
|
|||
m_opts.center.x += m_opts.borders[edge::LEFT].size;
|
||||
|
||||
m_log.trace("bar: Create renderer");
|
||||
auto fonts = m_conf.get_list<string>(m_conf.section(), "font", {});
|
||||
auto fonts = m_conf.get_list(m_conf.section(), "font", {});
|
||||
m_renderer = renderer::make(m_opts, move(fonts));
|
||||
|
||||
m_log.trace("bar: Attaching sink to registry");
|
||||
|
@ -315,7 +312,7 @@ const bar_settings bar::settings() const {
|
|||
* @param data Input string
|
||||
* @param force Unless true, do not parse unchanged data
|
||||
*/
|
||||
void bar::parse(const string& data, bool force) {
|
||||
void bar::parse(string&& data) {
|
||||
if (!m_mutex.try_lock()) {
|
||||
return;
|
||||
}
|
||||
|
@ -326,7 +323,7 @@ void bar::parse(const string& data, bool force) {
|
|||
return m_log.trace("bar: Ignoring update (shaded)");
|
||||
}
|
||||
|
||||
if (data == m_lastinput && !force) {
|
||||
if (data == m_lastinput) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -362,7 +359,7 @@ void bar::restack_window() {
|
|||
string wm_restack;
|
||||
|
||||
try {
|
||||
wm_restack = m_conf.get<string>(m_conf.section(), "wm-restack");
|
||||
wm_restack = m_conf.get(m_conf.section(), "wm-restack");
|
||||
} catch (const key_error& err) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "utils/factory.hpp"
|
||||
#include "utils/file.hpp"
|
||||
#include "utils/string.hpp"
|
||||
#include "x11/color.hpp"
|
||||
|
||||
POLYBAR_NS
|
||||
|
||||
|
@ -268,4 +269,9 @@ chrono::duration<double> config::convert(string&& value) const {
|
|||
return chrono::duration<double>{convert<double>(forward<string>(value))};
|
||||
}
|
||||
|
||||
template <>
|
||||
color config::convert(string&& value) const {
|
||||
return color{forward<string>(value)};
|
||||
}
|
||||
|
||||
POLYBAR_NS_END
|
||||
|
|
|
@ -86,11 +86,11 @@ controller::controller(connection& conn, signal_emitter& emitter, const logger&
|
|||
string configured_modules;
|
||||
|
||||
if (align == alignment::LEFT) {
|
||||
configured_modules = m_conf.get<string>(m_conf.section(), "modules-left", "");
|
||||
configured_modules = m_conf.get(m_conf.section(), "modules-left", ""s);
|
||||
} else if (align == alignment::CENTER) {
|
||||
configured_modules = m_conf.get<string>(m_conf.section(), "modules-center", "");
|
||||
configured_modules = m_conf.get(m_conf.section(), "modules-center", ""s);
|
||||
} else if (align == alignment::RIGHT) {
|
||||
configured_modules = m_conf.get<string>(m_conf.section(), "modules-right", "");
|
||||
configured_modules = m_conf.get(m_conf.section(), "modules-right", ""s);
|
||||
}
|
||||
|
||||
for (auto& module_name : string_util::split(configured_modules, ' ')) {
|
||||
|
@ -99,7 +99,7 @@ controller::controller(connection& conn, signal_emitter& emitter, const logger&
|
|||
}
|
||||
|
||||
try {
|
||||
auto type = m_conf.get<string>("module/" + module_name, "type");
|
||||
auto type = m_conf.get("module/" + module_name, "type");
|
||||
|
||||
if (type == "custom/ipc" && !m_ipc) {
|
||||
throw application_error("Inter-process messaging needs to be enabled");
|
||||
|
@ -240,7 +240,7 @@ void controller::read_events() {
|
|||
|
||||
vector<int> fds;
|
||||
fds.emplace_back(*m_queuefd[PIPE_READ]);
|
||||
fds.emplace_back(fd_connection = m_connection.get_file_descriptor());
|
||||
fds.emplace_back((fd_connection = m_connection.get_file_descriptor()));
|
||||
|
||||
if (m_confwatch) {
|
||||
m_log.trace("controller: Attach config watch");
|
||||
|
@ -484,7 +484,7 @@ bool controller::on(const sig_ev::update&) {
|
|||
|
||||
try {
|
||||
if (!m_writeback) {
|
||||
m_bar->parse(move(contents), false);
|
||||
m_bar->parse(move(contents));
|
||||
} else {
|
||||
std::cout << contents << std::endl;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ screen::screen(connection& conn, signal_emitter& emitter, const logger& logger,
|
|||
, m_monitors(randr_util::get_monitors(m_connection, m_root, true))
|
||||
, m_size({conn.screen()->width_in_pixels, conn.screen()->height_in_pixels}) {
|
||||
// Check if the reloading has been disabled by the user
|
||||
if (!m_conf.get<bool>("settings", "screenchange-reload", false)) {
|
||||
if (!m_conf.get("settings", "screenchange-reload", false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,9 +50,9 @@ namespace drawtypes {
|
|||
auto anim_defaults = load_optional_icon(conf, section, name);
|
||||
|
||||
if (required) {
|
||||
frames = conf.get_list<string>(section, name);
|
||||
frames = conf.get_list(section, name);
|
||||
} else {
|
||||
frames = conf.get_list<string>(section, name, {});
|
||||
frames = conf.get_list(section, name, {});
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < frames.size(); i++) {
|
||||
|
@ -60,7 +60,7 @@ namespace drawtypes {
|
|||
vec.back()->copy_undefined(anim_defaults);
|
||||
}
|
||||
|
||||
auto framerate = conf.get<int>(section, name + "-framerate", 1000);
|
||||
auto framerate = conf.get(section, name + "-framerate", 1000);
|
||||
|
||||
return factory_util::shared<animation>(move(vec), framerate);
|
||||
}
|
||||
|
|
|
@ -132,9 +132,9 @@ namespace drawtypes {
|
|||
}, margin{};
|
||||
|
||||
if (required) {
|
||||
text = conf.get<string>(section, name);
|
||||
text = conf.get(section, name);
|
||||
} else {
|
||||
text = conf.get<string>(section, name, move(def));
|
||||
text = conf.get(section, name, move(def));
|
||||
}
|
||||
|
||||
size_t len{text.size()};
|
||||
|
@ -144,9 +144,9 @@ namespace drawtypes {
|
|||
}
|
||||
|
||||
const auto get_left_right = [&](string key) {
|
||||
auto value = conf.get<int>(section, key, 0);
|
||||
auto left = conf.get<int>(section, key + "-left", value);
|
||||
auto right = conf.get<int>(section, key + "-right", value);
|
||||
auto value = conf.get(section, key, 0);
|
||||
auto left = conf.get(section, key + "-left", value);
|
||||
auto right = conf.get(section, key + "-right", value);
|
||||
return side_values{static_cast<uint16_t>(left), static_cast<uint16_t>(right)};
|
||||
};
|
||||
|
||||
|
@ -207,15 +207,15 @@ namespace drawtypes {
|
|||
|
||||
// clang-format off
|
||||
return factory_util::shared<label>(text,
|
||||
conf.get<string>(section, name + "-foreground", ""),
|
||||
conf.get<string>(section, name + "-background", ""),
|
||||
conf.get<string>(section, name + "-underline", ""),
|
||||
conf.get<string>(section, name + "-overline", ""),
|
||||
conf.get<int>(section, name + "-font", 0),
|
||||
conf.get(section, name + "-foreground", ""s),
|
||||
conf.get(section, name + "-background", ""s),
|
||||
conf.get(section, name + "-underline", ""s),
|
||||
conf.get(section, name + "-overline", ""s),
|
||||
conf.get(section, name + "-font", 0),
|
||||
padding,
|
||||
margin,
|
||||
conf.get<size_t>(section, name + "-maxlen", 0),
|
||||
conf.get<bool>(section, name + "-ellipsis", true),
|
||||
conf.get(section, name + "-maxlen", 0_z),
|
||||
conf.get(section, name + "-ellipsis", true),
|
||||
move(tokens));
|
||||
// clang-format on
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace drawtypes {
|
|||
string format = "%fill%%indicator%%empty%";
|
||||
unsigned int width;
|
||||
|
||||
if ((format = conf.get<decltype(format)>(section, name + "-format", format)).empty()) {
|
||||
if ((format = conf.get(section, name + "-format", format)).empty()) {
|
||||
throw application_error("Invalid format defined at [" + section + "." + name + "]");
|
||||
}
|
||||
if ((width = conf.get<decltype(width)>(section, name + "-width")) < 1) {
|
||||
|
@ -101,8 +101,8 @@ namespace drawtypes {
|
|||
}
|
||||
|
||||
auto pbar = factory_util::shared<progressbar>(bar, width, format);
|
||||
pbar->set_gradient(conf.get<bool>(section, name + "-gradient", true));
|
||||
pbar->set_colors(conf.get_list<string>(section, name + "-foreground", {}));
|
||||
pbar->set_gradient(conf.get(section, name + "-gradient", true));
|
||||
pbar->set_colors(conf.get_list(section, name + "-foreground", {}));
|
||||
|
||||
icon_t icon_empty;
|
||||
icon_t icon_fill;
|
||||
|
|
|
@ -106,7 +106,7 @@ int main(int argc, char** argv) {
|
|||
// Dump requested data
|
||||
//==================================================
|
||||
if (cli->has("dump")) {
|
||||
std::cout << conf.get<string>(conf.section(), cli->get("dump")) << std::endl;
|
||||
std::cout << conf.get(conf.section(), cli->get("dump")) << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
if (cli->has("print-wmname")) {
|
||||
|
@ -120,7 +120,7 @@ int main(int argc, char** argv) {
|
|||
unique_ptr<ipc> ipc{};
|
||||
unique_ptr<inotify_watch> config_watch{};
|
||||
|
||||
if (conf.get<bool>(conf.section(), "enable-ipc", false)) {
|
||||
if (conf.get(conf.section(), "enable-ipc", false)) {
|
||||
ipc = ipc::make();
|
||||
}
|
||||
if (cli->has("reload")) {
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace modules {
|
|||
|
||||
backlight_module::backlight_module(const bar_settings& bar, string name_)
|
||||
: inotify_module<backlight_module>(bar, move(name_)) {
|
||||
auto card = m_conf.get<string>(name(), "card");
|
||||
auto card = m_conf.get(name(), "card");
|
||||
|
||||
// Add formats and elements
|
||||
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL, {TAG_LABEL, TAG_BAR, TAG_RAMP});
|
||||
|
|
|
@ -20,8 +20,8 @@ namespace modules {
|
|||
*/
|
||||
battery_module::battery_module(const bar_settings& bar, string name_)
|
||||
: inotify_module<battery_module>(bar, move(name_)) {
|
||||
auto battery = m_conf.get<string>(name(), "battery", "BAT0");
|
||||
auto adapter = m_conf.get<string>(name(), "adapter", "ADP1");
|
||||
auto battery = m_conf.get(name(), "battery", "BAT0"s);
|
||||
auto adapter = m_conf.get(name(), "adapter", "ADP1"s);
|
||||
|
||||
auto path_adapter = string_util::replace(PATH_ADAPTER, "%adapter%", adapter) + "/";
|
||||
auto path_battery = string_util::replace(PATH_BATTERY, "%battery%", battery) + "/";
|
||||
|
@ -62,8 +62,8 @@ namespace modules {
|
|||
throw module_error("The file '" + path_battery + "[current|power]_now' does not exist");
|
||||
}
|
||||
|
||||
m_fullat = m_conf.get<int>(name(), "full-at", 100);
|
||||
m_interval = chrono::duration<double>{m_conf.get<float>(name(), "poll-interval", 5.0f)};
|
||||
m_fullat = m_conf.get(name(), "full-at", 100);
|
||||
m_interval = m_conf.get(name(), "poll-interval", 5s);
|
||||
m_lastpoll = chrono::system_clock::now();
|
||||
|
||||
// Load state and capacity level
|
||||
|
@ -105,7 +105,7 @@ namespace modules {
|
|||
if (!m_bar.locale.empty()) {
|
||||
setlocale(LC_TIME, m_bar.locale.c_str());
|
||||
}
|
||||
m_timeformat = m_conf.get<string>(name(), "time-format", "%H:%M:%S");
|
||||
m_timeformat = m_conf.get(name(), "time-format", "%H:%M:%S"s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,22 +16,13 @@ namespace {
|
|||
uint32_t make_mask(bspwm_state s1, bspwm_state s2 = bspwm_state::NONE) {
|
||||
uint32_t mask{0U};
|
||||
if (static_cast<uint32_t>(s1)) {
|
||||
mask |= 1 << (static_cast<uint32_t>(s1) - 1);
|
||||
mask |= 1U << (static_cast<uint32_t>(s1) - 1U);
|
||||
}
|
||||
if (static_cast<uint32_t>(s2)) {
|
||||
mask |= 1 << (static_cast<uint32_t>(s2) - 1);
|
||||
mask |= 1U << (static_cast<uint32_t>(s2) - 1U);
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
// uint32_t check_mask(uint32_t base, bspwm_state s1, bspwm_state s2 = bspwm_state::NONE) {
|
||||
// uint32_t mask{0U};
|
||||
// if (static_cast<uint32_t>(s1))
|
||||
// mask |= 1 << (static_cast<uint32_t>(s1) - 1);
|
||||
// if (static_cast<uint32_t>(s2))
|
||||
// mask |= 1 << (static_cast<uint32_t>(s2) - 1);
|
||||
// return (base & mask) == mask;
|
||||
// }
|
||||
}
|
||||
|
||||
namespace modules {
|
||||
|
@ -48,10 +39,10 @@ namespace modules {
|
|||
m_subscriber = bspwm_util::make_subscriber();
|
||||
|
||||
// Load configuration values
|
||||
GET_CONFIG_VALUE(name(), m_pinworkspaces, "pin-workspaces");
|
||||
GET_CONFIG_VALUE(name(), m_click, "enable-click");
|
||||
GET_CONFIG_VALUE(name(), m_scroll, "enable-scroll");
|
||||
GET_CONFIG_VALUE(name(), m_revscroll, "reverse-scroll");
|
||||
m_pinworkspaces = m_conf.get(name(), "pin-workspaces", m_pinworkspaces);
|
||||
m_click = m_conf.get(name(), "enable-click", m_click);
|
||||
m_scroll = m_conf.get(name(), "enable-scroll", m_scroll);
|
||||
m_revscroll = m_conf.get(name(), "reverse-scroll", m_revscroll);
|
||||
|
||||
// Add formats and create components
|
||||
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL_STATE, {TAG_LABEL_STATE}, {TAG_LABEL_MONITOR, TAG_LABEL_MODE});
|
||||
|
@ -120,7 +111,7 @@ namespace modules {
|
|||
}
|
||||
|
||||
m_icons = factory_util::shared<iconset>();
|
||||
m_icons->add(DEFAULT_ICON, factory_util::shared<label>(m_conf.get<string>(name(), DEFAULT_ICON, "")));
|
||||
m_icons->add(DEFAULT_ICON, factory_util::shared<label>(m_conf.get(name(), DEFAULT_ICON, ""s)));
|
||||
|
||||
for (const auto& workspace : m_conf.get_list<string>(name(), "ws-icon", {})) {
|
||||
auto vec = string_util::split(workspace, ';');
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace modules {
|
|||
template class module<cpu_module>;
|
||||
|
||||
cpu_module::cpu_module(const bar_settings& bar, string name_) : timer_module<cpu_module>(bar, move(name_)) {
|
||||
m_interval = chrono::duration<double>(m_conf.get<float>(name(), "interval", 1));
|
||||
m_interval = m_conf.get(name(), "interval", 1s);
|
||||
|
||||
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL, {TAG_LABEL, TAG_BAR_LOAD, TAG_RAMP_LOAD, TAG_RAMP_LOAD_PER_CORE});
|
||||
|
||||
|
|
|
@ -13,16 +13,16 @@ namespace modules {
|
|||
setlocale(LC_TIME, m_bar.locale.c_str());
|
||||
}
|
||||
|
||||
m_dateformat = string_util::trim(m_conf.get<string>(name(), "date", ""), '"');
|
||||
m_dateformat_alt = string_util::trim(m_conf.get<string>(name(), "date-alt", ""), '"');
|
||||
m_timeformat = string_util::trim(m_conf.get<string>(name(), "time", ""), '"');
|
||||
m_timeformat_alt = string_util::trim(m_conf.get<string>(name(), "time-alt", ""), '"');
|
||||
m_dateformat = string_util::trim(m_conf.get(name(), "date", ""s), '"');
|
||||
m_dateformat_alt = string_util::trim(m_conf.get(name(), "date-alt", ""s), '"');
|
||||
m_timeformat = string_util::trim(m_conf.get(name(), "time", ""s), '"');
|
||||
m_timeformat_alt = string_util::trim(m_conf.get(name(), "time-alt", ""s), '"');
|
||||
|
||||
if (m_dateformat.empty() && m_timeformat.empty()) {
|
||||
throw module_error("No date or time format specified");
|
||||
}
|
||||
|
||||
m_interval = chrono::duration<double>(m_conf.get<double>(name(), "interval", 1.0));
|
||||
m_interval = m_conf.get(name(), "interval", 1s);
|
||||
|
||||
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL, {TAG_LABEL, TAG_DATE});
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace modules {
|
|||
* setting up required components
|
||||
*/
|
||||
fs_module::fs_module(const bar_settings& bar, string name_) : timer_module<fs_module>(bar, move(name_)) {
|
||||
m_mountpoints = m_conf.get_list<string>(name(), "mount");
|
||||
m_mountpoints = m_conf.get_list(name(), "mount");
|
||||
m_remove_unmounted = m_conf.get(name(), "remove-unmounted", m_remove_unmounted);
|
||||
m_fixed = m_conf.get(name(), "fixed-values", m_fixed);
|
||||
m_spacing = m_conf.get(name(), "spacing", m_spacing);
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace modules {
|
|||
*/
|
||||
github_module::github_module(const bar_settings& bar, string name_)
|
||||
: timer_module<github_module>(bar, move(name_)), m_http(http_util::make_downloader()) {
|
||||
m_accesstoken = m_conf.get<string>(name(), "token");
|
||||
m_accesstoken = m_conf.get(name(), "token");
|
||||
m_interval = m_conf.get(name(), "interval", 60s);
|
||||
m_empty_notifications = m_conf.get(name(), "empty-notifications", m_empty_notifications);
|
||||
|
||||
|
|
|
@ -23,13 +23,13 @@ namespace modules {
|
|||
m_ipc = factory_util::unique<i3ipc::connection>();
|
||||
|
||||
// Load configuration values
|
||||
GET_CONFIG_VALUE(name(), m_click, "enable-click");
|
||||
GET_CONFIG_VALUE(name(), m_scroll, "enable-scroll");
|
||||
GET_CONFIG_VALUE(name(), m_revscroll, "reverse-scroll");
|
||||
GET_CONFIG_VALUE(name(), m_wrap, "wrapping-scroll");
|
||||
GET_CONFIG_VALUE(name(), m_indexsort, "index-sort");
|
||||
GET_CONFIG_VALUE(name(), m_pinworkspaces, "pin-workspaces");
|
||||
GET_CONFIG_VALUE(name(), m_strip_wsnumbers, "strip-wsnumbers");
|
||||
m_click = m_conf.get(name(), "enable-click", m_click);
|
||||
m_scroll = m_conf.get(name(), "enable-scroll", m_scroll);
|
||||
m_revscroll = m_conf.get(name(), "reverse-scroll", m_revscroll);
|
||||
m_wrap = m_conf.get(name(), "wrapping-scroll", m_wrap);
|
||||
m_indexsort = m_conf.get(name(), "index-sort", m_indexsort);
|
||||
m_pinworkspaces = m_conf.get(name(), "pin-workspaces", m_pinworkspaces);
|
||||
m_strip_wsnumbers = m_conf.get(name(), "strip-wsnumbers", m_strip_wsnumbers);
|
||||
|
||||
m_conf.warn_deprecated(name(), "wsname-maxlen", "%name:min:max%");
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace modules {
|
|||
}
|
||||
|
||||
m_icons = factory_util::shared<iconset>();
|
||||
m_icons->add(DEFAULT_WS_ICON, factory_util::shared<label>(m_conf.get<string>(name(), DEFAULT_WS_ICON, "")));
|
||||
m_icons->add(DEFAULT_WS_ICON, factory_util::shared<label>(m_conf.get(name(), DEFAULT_WS_ICON, ""s)));
|
||||
|
||||
for (const auto& workspace : m_conf.get_list<string>(name(), "ws-icon", {})) {
|
||||
auto vec = string_util::split(workspace, ';');
|
||||
|
|
|
@ -24,11 +24,11 @@ namespace modules {
|
|||
throw module_error("No ipc hooks defined");
|
||||
}
|
||||
|
||||
m_actions[mousebtn::LEFT] = m_conf.get<string>(name(), "click-left", "");
|
||||
m_actions[mousebtn::MIDDLE] = m_conf.get<string>(name(), "click-middle", "");
|
||||
m_actions[mousebtn::RIGHT] = m_conf.get<string>(name(), "click-right", "");
|
||||
m_actions[mousebtn::SCROLL_UP] = m_conf.get<string>(name(), "scroll-up", "");
|
||||
m_actions[mousebtn::SCROLL_DOWN] = m_conf.get<string>(name(), "scroll-down", "");
|
||||
m_actions[mousebtn::LEFT] = m_conf.get(name(), "click-left", ""s);
|
||||
m_actions[mousebtn::MIDDLE] = m_conf.get(name(), "click-middle", ""s);
|
||||
m_actions[mousebtn::RIGHT] = m_conf.get(name(), "click-right", ""s);
|
||||
m_actions[mousebtn::SCROLL_UP] = m_conf.get(name(), "scroll-up", ""s);
|
||||
m_actions[mousebtn::SCROLL_DOWN] = m_conf.get(name(), "scroll-down", ""s);
|
||||
|
||||
m_formatter->add(DEFAULT_FORMAT, TAG_OUTPUT, {TAG_OUTPUT});
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace modules {
|
|||
template class module<memory_module>;
|
||||
|
||||
memory_module::memory_module(const bar_settings& bar, string name_) : timer_module<memory_module>(bar, move(name_)) {
|
||||
m_interval = chrono::duration<double>(m_conf.get<float>(name(), "interval", 1));
|
||||
m_interval = m_conf.get(name(), "interval", 1s);
|
||||
|
||||
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL, {TAG_LABEL, TAG_BAR_USED, TAG_BAR_FREE});
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace modules {
|
|||
while (true) {
|
||||
string level_param{"menu-" + to_string(m_levels.size())};
|
||||
|
||||
if (m_conf.get<string>(name(), level_param + "-0", "").empty()) {
|
||||
if (m_conf.get(name(), level_param + "-0", ""s).empty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -40,14 +40,14 @@ namespace modules {
|
|||
while (true) {
|
||||
string item_param{level_param + "-" + to_string(m_levels.back()->items.size())};
|
||||
|
||||
if (m_conf.get<string>(name(), item_param, "").empty()) {
|
||||
if (m_conf.get(name(), item_param, ""s).empty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
m_log.trace("%s: Creating menu level item %i", name(), m_levels.back()->items.size());
|
||||
auto item = factory_util::unique<menu_tree_item>();
|
||||
item->label = load_label(m_conf, name(), item_param);
|
||||
item->exec = m_conf.get<string>(name(), item_param + "-exec", EVENT_MENU_CLOSE);
|
||||
item->exec = m_conf.get(name(), item_param + "-exec", string{EVENT_MENU_CLOSE});
|
||||
m_levels.back()->items.emplace_back(move(item));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace modules {
|
|||
|
||||
auto format = make_unique<module_format>();
|
||||
|
||||
format->value = m_conf.get<string>(m_modname, name, move(fallback));
|
||||
format->value = m_conf.get(m_modname, name, move(fallback));
|
||||
format->fg = m_conf.get(m_modname, name + "-foreground", ""s);
|
||||
format->bg = m_conf.get(m_modname, name + "-background", ""s);
|
||||
format->ul = m_conf.get(m_modname, name + "-underline", ""s);
|
||||
|
|
|
@ -70,8 +70,8 @@ namespace modules {
|
|||
}
|
||||
if (m_formatter->has(TAG_ICON_RANDOM) || m_formatter->has(TAG_ICON_REPEAT) ||
|
||||
m_formatter->has(TAG_ICON_REPEAT_ONE)) {
|
||||
m_toggle_on_color = m_conf.get<string>(name(), "toggle-on-foreground", "");
|
||||
m_toggle_off_color = m_conf.get<string>(name(), "toggle-off-foreground", "");
|
||||
m_toggle_on_color = m_conf.get(name(), "toggle-on-foreground", ""s);
|
||||
m_toggle_off_color = m_conf.get(name(), "toggle-off-foreground", ""s);
|
||||
}
|
||||
if (m_formatter->has(TAG_LABEL_OFFLINE, FORMAT_OFFLINE)) {
|
||||
m_label_offline = load_label(m_conf, name(), TAG_LABEL_OFFLINE);
|
||||
|
|
|
@ -15,15 +15,14 @@ namespace modules {
|
|||
network_module::network_module(const bar_settings& bar, string name_)
|
||||
: timer_module<network_module>(bar, move(name_)) {
|
||||
// Load configuration values
|
||||
REQ_CONFIG_VALUE(name(), m_interface, "interface");
|
||||
GET_CONFIG_VALUE(name(), m_ping_nth_update, "ping-interval");
|
||||
GET_CONFIG_VALUE(name(), m_udspeed_minwidth, "udspeed-minwidth");
|
||||
GET_CONFIG_VALUE(name(), m_accumulate, "accumulate-stats");
|
||||
m_interface = m_conf.get(name(), "interface", m_interface);
|
||||
m_ping_nth_update = m_conf.get(name(), "ping-interval", m_ping_nth_update);
|
||||
m_udspeed_minwidth = m_conf.get(name(), "udspeed-minwidth", m_udspeed_minwidth);
|
||||
m_accumulate = m_conf.get(name(), "accumulate-stats", m_accumulate);
|
||||
m_interval = m_conf.get(name(), "interval", 1s);
|
||||
|
||||
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
|
||||
m_formatter->add(FORMAT_CONNECTED, TAG_LABEL_CONNECTED, {TAG_RAMP_SIGNAL, TAG_RAMP_QUALITY, TAG_LABEL_CONNECTED});
|
||||
m_formatter->add(FORMAT_DISCONNECTED, TAG_LABEL_DISCONNECTED, {TAG_LABEL_DISCONNECTED});
|
||||
|
|
|
@ -9,21 +9,20 @@ namespace modules {
|
|||
template class module<script_module>;
|
||||
|
||||
script_module::script_module(const bar_settings& bar, string name_) : event_module<script_module>(bar, move(name_)) {
|
||||
REQ_CONFIG_VALUE(name(), m_exec, "exec");
|
||||
GET_CONFIG_VALUE(name(), m_tail, "tail");
|
||||
GET_CONFIG_VALUE(name(), m_maxlen, "maxlen");
|
||||
GET_CONFIG_VALUE(name(), m_ellipsis, "ellipsis");
|
||||
m_exec = m_conf.get(name(), "exec", m_exec);
|
||||
m_tail = m_conf.get(name(), "tail", m_tail);
|
||||
m_maxlen = m_conf.get(name(), "maxlen", m_maxlen);
|
||||
m_ellipsis = m_conf.get(name(), "ellipsis", m_ellipsis);
|
||||
m_interval = m_conf.get(name(), "interval", m_tail ? 0s : 5s);
|
||||
|
||||
m_conf.warn_deprecated(
|
||||
name(), "maxlen", "\"format = <label>\" and \"label = %output:0:" + to_string(m_maxlen) + "%\"");
|
||||
|
||||
m_actions[mousebtn::LEFT] = m_conf.get<string>(name(), "click-left", "");
|
||||
m_actions[mousebtn::MIDDLE] = m_conf.get<string>(name(), "click-middle", "");
|
||||
m_actions[mousebtn::RIGHT] = m_conf.get<string>(name(), "click-right", "");
|
||||
m_actions[mousebtn::SCROLL_UP] = m_conf.get<string>(name(), "scroll-up", "");
|
||||
m_actions[mousebtn::SCROLL_DOWN] = m_conf.get<string>(name(), "scroll-down", "");
|
||||
|
||||
m_interval = chrono::duration<double>{m_conf.get<double>(name(), "interval", m_tail ? 0.0 : 5.0)};
|
||||
m_actions[mousebtn::LEFT] = m_conf.get(name(), "click-left", ""s);
|
||||
m_actions[mousebtn::MIDDLE] = m_conf.get(name(), "click-middle", ""s);
|
||||
m_actions[mousebtn::RIGHT] = m_conf.get(name(), "click-right", ""s);
|
||||
m_actions[mousebtn::SCROLL_UP] = m_conf.get(name(), "scroll-up", ""s);
|
||||
m_actions[mousebtn::SCROLL_DOWN] = m_conf.get(name(), "scroll-down", ""s);
|
||||
|
||||
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL, {TAG_OUTPUT, TAG_LABEL});
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@ namespace modules {
|
|||
|
||||
temperature_module::temperature_module(const bar_settings& bar, string name_)
|
||||
: timer_module<temperature_module>(bar, move(name_)) {
|
||||
m_zone = m_conf.get<int>(name(), "thermal-zone", 0);
|
||||
m_tempwarn = m_conf.get<int>(name(), "warn-temperature", 80);
|
||||
m_interval = chrono::duration<double>(m_conf.get<float>(name(), "interval", 1));
|
||||
m_zone = m_conf.get(name(), "thermal-zone", 0);
|
||||
m_tempwarn = m_conf.get(name(), "warn-temperature", 80);
|
||||
m_interval = m_conf.get(name(), "interval", 1s);
|
||||
|
||||
m_path = string_util::replace(PATH_TEMPERATURE_INFO, "%zone%", to_string(m_zone));
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ namespace modules {
|
|||
// with the cmd handlers
|
||||
string output{module::get_output()};
|
||||
|
||||
auto click_left = m_conf.get<string>(name(), "click-left", "");
|
||||
auto click_middle = m_conf.get<string>(name(), "click-middle", "");
|
||||
auto click_right = m_conf.get<string>(name(), "click-right", "");
|
||||
auto scroll_up = m_conf.get<string>(name(), "scroll-up", "");
|
||||
auto scroll_down = m_conf.get<string>(name(), "scroll-down", "");
|
||||
auto click_left = m_conf.get(name(), "click-left", ""s);
|
||||
auto click_middle = m_conf.get(name(), "click-middle", ""s);
|
||||
auto click_right = m_conf.get(name(), "click-right", ""s);
|
||||
auto scroll_up = m_conf.get(name(), "scroll-up", ""s);
|
||||
auto scroll_down = m_conf.get(name(), "scroll-down", ""s);
|
||||
|
||||
if (!click_left.empty()) {
|
||||
m_builder->cmd(mousebtn::LEFT, click_left);
|
||||
|
|
|
@ -18,17 +18,14 @@ namespace modules {
|
|||
|
||||
volume_module::volume_module(const bar_settings& bar, string name_) : event_module<volume_module>(bar, move(name_)) {
|
||||
// Load configuration values
|
||||
string master_mixer_name{"Master"};
|
||||
string speaker_mixer_name;
|
||||
string headphone_mixer_name;
|
||||
m_mapped = m_conf.get(name(), "mapped", m_mapped);
|
||||
|
||||
GET_CONFIG_VALUE(name(), master_mixer_name, "master-mixer");
|
||||
GET_CONFIG_VALUE(name(), speaker_mixer_name, "speaker-mixer");
|
||||
GET_CONFIG_VALUE(name(), headphone_mixer_name, "headphone-mixer");
|
||||
GET_CONFIG_VALUE(name(), m_mapped, "mapped");
|
||||
auto master_mixer_name = m_conf.get(name(), "master-mixer", "Master"s);
|
||||
auto speaker_mixer_name = m_conf.get(name(), "speaker-mixer", ""s);
|
||||
auto headphone_mixer_name = m_conf.get(name(), "headphone-mixer", ""s);
|
||||
|
||||
if (!headphone_mixer_name.empty()) {
|
||||
REQ_CONFIG_VALUE(name(), m_headphoneid, "headphone-id");
|
||||
m_headphoneid = m_conf.get<decltype(m_headphoneid)>(name(), "headphone-id");
|
||||
}
|
||||
|
||||
if (string_util::compare(speaker_mixer_name, "master")) {
|
||||
|
|
|
@ -19,8 +19,8 @@ namespace modules {
|
|||
*/
|
||||
xbacklight_module::xbacklight_module(const bar_settings& bar, string name_)
|
||||
: static_module<xbacklight_module>(bar, move(name_)), m_connection(connection::make()) {
|
||||
auto output = m_conf.get<string>(name(), "output", m_bar.monitor->name);
|
||||
auto strict = m_conf.get<bool>(name(), "monitor-strict", false);
|
||||
auto output = m_conf.get(name(), "output", m_bar.monitor->name);
|
||||
auto strict = m_conf.get(name(), "monitor-strict", false);
|
||||
|
||||
// Grab a list of all outputs and try to find the one defined in the config
|
||||
for (auto&& mon : randr_util::get_monitors(m_connection, m_connection.root(), strict)) {
|
||||
|
@ -36,7 +36,7 @@ namespace modules {
|
|||
}
|
||||
|
||||
// Get flag to check if we should add scroll handlers for changing value
|
||||
GET_CONFIG_VALUE(name(), m_scroll, "enable-scroll");
|
||||
m_scroll = m_conf.get(name(), "enable-scroll", m_scroll);
|
||||
|
||||
// Query randr for the backlight max and min value
|
||||
try {
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace modules {
|
|||
xkeyboard_module::xkeyboard_module(const bar_settings& bar, string name_)
|
||||
: static_module<xkeyboard_module>(bar, move(name_)), m_connection(connection::make()) {
|
||||
// Load config values
|
||||
m_blacklist = m_conf.get_list<string>(name(), "blacklist", {});
|
||||
m_blacklist = m_conf.get_list(name(), "blacklist", {});
|
||||
|
||||
// Add formats and elements
|
||||
m_formatter->add(DEFAULT_FORMAT, FORMAT_DEFAULT, {TAG_LABEL_LAYOUT, TAG_LABEL_INDICATOR});
|
||||
|
|
|
@ -21,9 +21,9 @@ namespace modules {
|
|||
xworkspaces_module::xworkspaces_module(const bar_settings& bar, string name_)
|
||||
: static_module<xworkspaces_module>(bar, move(name_)), m_connection(connection::make()) {
|
||||
// Load config values
|
||||
m_pinworkspaces = m_conf.get<bool>(name(), "pin-workspaces", m_pinworkspaces);
|
||||
m_click = m_conf.get<bool>(name(), "enable-click", m_click);
|
||||
m_scroll = m_conf.get<bool>(name(), "enable-scroll", m_scroll);
|
||||
m_pinworkspaces = m_conf.get(name(), "pin-workspaces", m_pinworkspaces);
|
||||
m_click = m_conf.get(name(), "enable-click", m_click);
|
||||
m_scroll = m_conf.get(name(), "enable-scroll", m_scroll);
|
||||
|
||||
// Initialize ewmh atoms
|
||||
if ((m_ewmh = ewmh_util::initialize()) == nullptr) {
|
||||
|
@ -66,7 +66,7 @@ namespace modules {
|
|||
}
|
||||
|
||||
m_icons = factory_util::shared<iconset>();
|
||||
m_icons->add(DEFAULT_ICON, factory_util::shared<label>(m_conf.get<string>(name(), DEFAULT_ICON, "")));
|
||||
m_icons->add(DEFAULT_ICON, factory_util::shared<label>(m_conf.get(name(), DEFAULT_ICON, ""s)));
|
||||
|
||||
for (const auto& workspace : m_conf.get_list<string>(name(), "icon", {})) {
|
||||
auto vec = string_util::split(workspace, ';');
|
||||
|
|
|
@ -65,13 +65,14 @@ tray_manager::~tray_manager() {
|
|||
void tray_manager::setup(const bar_settings& bar_opts) {
|
||||
auto conf = config::make();
|
||||
auto bs = conf.section();
|
||||
string position;
|
||||
|
||||
if (!conf.has(bs, "tray-position")) {
|
||||
try {
|
||||
position = conf.get(bs, "tray-position");
|
||||
} catch (const key_error& err) {
|
||||
return m_log.info("Disabling tray manager (reason: missing `tray-position`)");
|
||||
}
|
||||
|
||||
auto position = conf.get<string>(bs, "tray-position");
|
||||
|
||||
if (position == "left") {
|
||||
m_opts.align = alignment::LEFT;
|
||||
} else if (position == "right") {
|
||||
|
@ -82,7 +83,7 @@ void tray_manager::setup(const bar_settings& bar_opts) {
|
|||
return m_log.err("Disabling tray manager (reason: Invalid position \"" + position + "\")");
|
||||
}
|
||||
|
||||
m_opts.detached = conf.get<bool>(bs, "tray-detached", false);
|
||||
m_opts.detached = conf.get(bs, "tray-detached", false);
|
||||
m_opts.height = bar_opts.size.h;
|
||||
m_opts.height -= bar_opts.borders.at(edge::BOTTOM).size;
|
||||
m_opts.height -= bar_opts.borders.at(edge::TOP).size;
|
||||
|
@ -92,7 +93,7 @@ void tray_manager::setup(const bar_settings& bar_opts) {
|
|||
m_opts.height--;
|
||||
}
|
||||
|
||||
auto maxsize = conf.get<int>(bs, "tray-maxsize", 16);
|
||||
auto maxsize = conf.get(bs, "tray-maxsize", 16);
|
||||
if (m_opts.height > maxsize) {
|
||||
m_opts.spacing += (m_opts.height - maxsize) / 2;
|
||||
m_opts.height = maxsize;
|
||||
|
@ -103,7 +104,7 @@ void tray_manager::setup(const bar_settings& bar_opts) {
|
|||
m_opts.orig_y = bar_opts.pos.y + bar_opts.borders.at(edge::TOP).size;
|
||||
|
||||
// Apply user-defined scaling
|
||||
auto scale = conf.get<float>(bs, "tray-scale", 1.0);
|
||||
auto scale = conf.get(bs, "tray-scale", 1.0f);
|
||||
m_opts.width *= scale;
|
||||
m_opts.height_fill *= scale;
|
||||
|
||||
|
@ -124,8 +125,8 @@ void tray_manager::setup(const bar_settings& bar_opts) {
|
|||
}
|
||||
|
||||
// Set user-defined background color
|
||||
if (!(m_opts.transparent = conf.get<bool>(bs, "tray-transparent", m_opts.transparent))) {
|
||||
auto bg = conf.get<string>(bs, "tray-background", "");
|
||||
if (!(m_opts.transparent = conf.get(bs, "tray-transparent", m_opts.transparent))) {
|
||||
auto bg = conf.get(bs, "tray-background", ""s);
|
||||
|
||||
if (bg.length() > 7) {
|
||||
m_log.warn("Alpha support for the systray is limited. See the wiki for more details.");
|
||||
|
@ -144,11 +145,11 @@ void tray_manager::setup(const bar_settings& bar_opts) {
|
|||
}
|
||||
|
||||
// Add user-defined padding
|
||||
m_opts.spacing += conf.get<int>(bs, "tray-padding", 0);
|
||||
m_opts.spacing += conf.get(bs, "tray-padding", 0);
|
||||
|
||||
// Add user-defiend offset
|
||||
auto offset_x_def = conf.get<string>(bs, "tray-offset-x", "");
|
||||
auto offset_y_def = conf.get<string>(bs, "tray-offset-y", "");
|
||||
auto offset_x_def = conf.get(bs, "tray-offset-x", ""s);
|
||||
auto offset_y_def = conf.get(bs, "tray-offset-y", ""s);
|
||||
|
||||
auto offset_x = atoi(offset_x_def.c_str());
|
||||
auto offset_y = atoi(offset_y_def.c_str());
|
||||
|
|
Loading…
Reference in a new issue