1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00
polybar/include/modules/text.hpp

52 lines
1.5 KiB
C++
Raw Normal View History

#pragma once
2016-05-19 10:41:06 -04:00
2016-06-14 23:32:35 -04:00
#include "modules/meta.hpp"
2016-05-19 10:41:06 -04:00
2016-06-14 23:32:35 -04:00
LEMONBUDDY_NS
namespace modules {
class text_module : public static_module<text_module> {
public:
using static_module::static_module;
void setup() {
m_formatter->add("content", "", {});
if (m_formatter->get("content")->value.empty())
throw module_error(name() + ".content is empty or undefined");
m_formatter->get("content")->value =
string_util::replace_all(m_formatter->get("content")->value, " ", BUILDER_SPACE_TOKEN);
2016-06-14 23:32:35 -04:00
}
string get_format() const {
return "content";
2016-06-14 23:32:35 -04:00
}
string 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", "");
2016-05-19 10:41:06 -04:00
2016-06-14 23:32:35 -04:00
if (!click_left.empty())
m_builder->cmd(mousebtn::LEFT, click_left);
if (!click_middle.empty())
m_builder->cmd(mousebtn::MIDDLE, click_middle);
if (!click_right.empty())
m_builder->cmd(mousebtn::RIGHT, click_right);
if (!scroll_up.empty())
m_builder->cmd(mousebtn::SCROLL_UP, scroll_up);
if (!scroll_down.empty())
m_builder->cmd(mousebtn::SCROLL_DOWN, scroll_down);
2016-05-19 10:41:06 -04:00
2016-06-14 23:32:35 -04:00
m_builder->node(module::get_output());
return m_builder->flush();
}
2016-05-19 10:41:06 -04:00
};
}
2016-06-14 23:32:35 -04:00
LEMONBUDDY_NS_END