mirror of https://github.com/polybar/polybar.git
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:
parent
a77923ea96
commit
587dc6c84d
|
@ -10,10 +10,6 @@ POLYBAR_NS
|
||||||
using std::map;
|
using std::map;
|
||||||
|
|
||||||
// fwd decl
|
// fwd decl
|
||||||
namespace drawtypes {
|
|
||||||
class label;
|
|
||||||
using label_t = shared_ptr<label>;
|
|
||||||
} // namespace drawtypes
|
|
||||||
using namespace drawtypes;
|
using namespace drawtypes;
|
||||||
|
|
||||||
class builder {
|
class builder {
|
||||||
|
|
|
@ -12,6 +12,12 @@ POLYBAR_NS
|
||||||
// fwd {{{
|
// fwd {{{
|
||||||
struct randr_output;
|
struct randr_output;
|
||||||
using monitor_t = shared_ptr<randr_output>;
|
using monitor_t = shared_ptr<randr_output>;
|
||||||
|
|
||||||
|
namespace drawtypes {
|
||||||
|
class label;
|
||||||
|
}
|
||||||
|
|
||||||
|
using label_t = shared_ptr<drawtypes::label>;
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
struct enum_hash {
|
struct enum_hash {
|
||||||
|
@ -159,7 +165,7 @@ struct bar_settings {
|
||||||
|
|
||||||
struct radius radius {};
|
struct radius radius {};
|
||||||
int spacing{0};
|
int spacing{0};
|
||||||
string separator{};
|
label_t separator{};
|
||||||
|
|
||||||
string wmname{};
|
string wmname{};
|
||||||
string locale{};
|
string locale{};
|
||||||
|
|
|
@ -18,9 +18,6 @@ namespace drawtypes {
|
||||||
bool zpad{false};
|
bool zpad{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
class label;
|
|
||||||
using label_t = shared_ptr<label>;
|
|
||||||
|
|
||||||
class label : public non_copyable_mixin<label> {
|
class label : public non_copyable_mixin<label> {
|
||||||
public:
|
public:
|
||||||
string m_foreground{};
|
string m_foreground{};
|
||||||
|
|
|
@ -9,10 +9,6 @@
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
namespace drawtypes {
|
namespace drawtypes {
|
||||||
// fwd
|
|
||||||
class label;
|
|
||||||
using label_t = shared_ptr<label>;
|
|
||||||
|
|
||||||
class progressbar : public non_copyable_mixin<progressbar> {
|
class progressbar : public non_copyable_mixin<progressbar> {
|
||||||
public:
|
public:
|
||||||
explicit progressbar(const bar_settings& bar, int width, string format);
|
explicit progressbar(const bar_settings& bar, int width, string format);
|
||||||
|
|
|
@ -29,8 +29,6 @@ using std::map;
|
||||||
// fwd decl {{{
|
// fwd decl {{{
|
||||||
|
|
||||||
namespace drawtypes {
|
namespace drawtypes {
|
||||||
class label;
|
|
||||||
using label_t = shared_ptr<label>;
|
|
||||||
class ramp;
|
class ramp;
|
||||||
using ramp_t = shared_ptr<ramp>;
|
using ramp_t = shared_ptr<ramp>;
|
||||||
class progressbar;
|
class progressbar;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "components/screen.hpp"
|
#include "components/screen.hpp"
|
||||||
#include "components/taskqueue.hpp"
|
#include "components/taskqueue.hpp"
|
||||||
#include "components/types.hpp"
|
#include "components/types.hpp"
|
||||||
|
#include "drawtypes/label.hpp"
|
||||||
#include "events/signal.hpp"
|
#include "events/signal.hpp"
|
||||||
#include "events/signal_emitter.hpp"
|
#include "events/signal_emitter.hpp"
|
||||||
#include "utils/bspwm.hpp"
|
#include "utils/bspwm.hpp"
|
||||||
|
@ -155,7 +156,7 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const
|
||||||
// Load configuration values
|
// Load configuration values
|
||||||
m_opts.origin = m_conf.get(bs, "bottom", false) ? edge::BOTTOM : edge::TOP;
|
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.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);
|
m_opts.locale = m_conf.get(bs, "locale", ""s);
|
||||||
|
|
||||||
auto radius = m_conf.get<double>(bs, "radius", 0.0);
|
auto radius = m_conf.get<double>(bs, "radius", 0.0);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
|
|
||||||
#include "components/bar.hpp"
|
#include "components/bar.hpp"
|
||||||
|
#include "components/builder.hpp"
|
||||||
#include "components/config.hpp"
|
#include "components/config.hpp"
|
||||||
#include "components/ipc.hpp"
|
#include "components/ipc.hpp"
|
||||||
#include "components/logger.hpp"
|
#include "components/logger.hpp"
|
||||||
|
@ -447,12 +448,15 @@ void controller::process_inputdata() {
|
||||||
bool controller::process_update(bool force) {
|
bool controller::process_update(bool force) {
|
||||||
const bar_settings& bar{m_bar->settings()};
|
const bar_settings& bar{m_bar->settings()};
|
||||||
string contents;
|
string contents;
|
||||||
string separator{bar.separator};
|
|
||||||
string padding_left(bar.padding.left, ' ');
|
string padding_left(bar.padding.left, ' ');
|
||||||
string padding_right(bar.padding.right, ' ');
|
string padding_right(bar.padding.right, ' ');
|
||||||
string margin_left(bar.module_margin.left, ' ');
|
string margin_left(bar.module_margin.left, ' ');
|
||||||
string margin_right(bar.module_margin.right, ' ');
|
string margin_right(bar.module_margin.right, ' ');
|
||||||
|
|
||||||
|
builder build{bar};
|
||||||
|
build.node(bar.separator);
|
||||||
|
string separator{build.flush()};
|
||||||
|
|
||||||
for (const auto& block : m_blocks) {
|
for (const auto& block : m_blocks) {
|
||||||
string block_contents;
|
string block_contents;
|
||||||
bool is_left = false;
|
bool is_left = false;
|
||||||
|
|
Loading…
Reference in New Issue