bar: Make module separator a label

Some people use text modules instead of the `separator` key in the bar
section to better configure the separator (colors, fonts).
Since we disallowed the same module being used multiple times in #1534,
this will now print an error message.

This should help with this a bit.

Ref #1913
This commit is contained in:
patrick96 2019-10-27 13:32:45 +01:00 committed by Patrick Ziegler
parent a77923ea96
commit 587dc6c84d
7 changed files with 14 additions and 16 deletions

View File

@ -10,10 +10,6 @@ POLYBAR_NS
using std::map;
// fwd decl
namespace drawtypes {
class label;
using label_t = shared_ptr<label>;
} // namespace drawtypes
using namespace drawtypes;
class builder {

View File

@ -12,6 +12,12 @@ POLYBAR_NS
// fwd {{{
struct randr_output;
using monitor_t = shared_ptr<randr_output>;
namespace drawtypes {
class label;
}
using label_t = shared_ptr<drawtypes::label>;
// }}}
struct enum_hash {
@ -159,7 +165,7 @@ struct bar_settings {
struct radius radius {};
int spacing{0};
string separator{};
label_t separator{};
string wmname{};
string locale{};

View File

@ -18,9 +18,6 @@ namespace drawtypes {
bool zpad{false};
};
class label;
using label_t = shared_ptr<label>;
class label : public non_copyable_mixin<label> {
public:
string m_foreground{};

View File

@ -9,10 +9,6 @@
POLYBAR_NS
namespace drawtypes {
// fwd
class label;
using label_t = shared_ptr<label>;
class progressbar : public non_copyable_mixin<progressbar> {
public:
explicit progressbar(const bar_settings& bar, int width, string format);

View File

@ -29,8 +29,6 @@ using std::map;
// fwd decl {{{
namespace drawtypes {
class label;
using label_t = shared_ptr<label>;
class ramp;
using ramp_t = shared_ptr<ramp>;
class progressbar;

View File

@ -7,6 +7,7 @@
#include "components/screen.hpp"
#include "components/taskqueue.hpp"
#include "components/types.hpp"
#include "drawtypes/label.hpp"
#include "events/signal.hpp"
#include "events/signal_emitter.hpp"
#include "utils/bspwm.hpp"
@ -155,7 +156,7 @@ 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.separator = m_conf.get(bs, "separator", ""s);
m_opts.separator = drawtypes::load_optional_label(m_conf, bs, "separator", "");
m_opts.locale = m_conf.get(bs, "locale", ""s);
auto radius = m_conf.get<double>(bs, "radius", 0.0);

View File

@ -3,6 +3,7 @@
#include <csignal>
#include "components/bar.hpp"
#include "components/builder.hpp"
#include "components/config.hpp"
#include "components/ipc.hpp"
#include "components/logger.hpp"
@ -447,12 +448,15 @@ void controller::process_inputdata() {
bool controller::process_update(bool force) {
const bar_settings& bar{m_bar->settings()};
string contents;
string separator{bar.separator};
string padding_left(bar.padding.left, ' ');
string padding_right(bar.padding.right, ' ');
string margin_left(bar.module_margin.left, ' ');
string margin_right(bar.module_margin.right, ' ');
builder build{bar};
build.node(bar.separator);
string separator{build.flush()};
for (const auto& block : m_blocks) {
string block_contents;
bool is_left = false;