From ca1aac2ed667ce99aded9cc31947a2724d5b04b9 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Thu, 12 Jan 2017 17:32:11 +0100 Subject: [PATCH] feat(config): Shorthand for {padding,module-margin}-{left,right} --- src/components/bar.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/components/bar.cpp b/src/components/bar.cpp index c1aedd1b..8b0dade3 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -134,13 +134,27 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const // Load configuration values 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.separator = m_conf.get(bs, "separator", ""s); m_opts.locale = m_conf.get(bs, "locale", ""s); + try { + auto padding = m_conf.get(bs, "module-padding"); + m_opts.padding.left = padding; + m_opts.padding.right = padding; + } catch (const key_error& err) { + 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); + } + + try { + auto margin = m_conf.get(bs, "module-margin"); + m_opts.module_margin.left = margin; + m_opts.module_margin.right = margin; + } catch (const key_error& err) { + 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); + } + if (only_initialize_values) { return; }