mirror of https://github.com/polybar/polybar.git
fix(script): Make sure the output is passed through the formatter
Fixes jaagr/lemonbuddy#97
This commit is contained in:
parent
4a49ba340c
commit
ba1939f4ca
|
@ -57,7 +57,7 @@ namespace modules {
|
||||||
// }}}
|
// }}}
|
||||||
// Terminate running command {{{
|
// Terminate running command {{{
|
||||||
try {
|
try {
|
||||||
if (m_command)
|
if (m_tail && m_command)
|
||||||
m_command.reset();
|
m_command.reset();
|
||||||
} catch (const std::exception& err) {
|
} catch (const std::exception& err) {
|
||||||
m_log.err("%s: %s", name(), err.what());
|
m_log.err("%s: %s", name(), err.what());
|
||||||
|
@ -117,14 +117,14 @@ namespace modules {
|
||||||
}
|
}
|
||||||
|
|
||||||
string get_output() {
|
string get_output() {
|
||||||
auto output = string_util::replace_all(m_output, "\n", "");
|
if (m_output.empty())
|
||||||
if (output.empty())
|
|
||||||
return " ";
|
return " ";
|
||||||
|
|
||||||
// Truncate output to the defined max length {{{
|
// Truncate output to the defined max length {{{
|
||||||
if (m_maxlen > 0 && output.length() > m_maxlen) {
|
|
||||||
output.erase(m_maxlen);
|
if (m_maxlen > 0 && m_output.length() > m_maxlen) {
|
||||||
output += m_ellipsis ? "..." : "";
|
m_output.erase(m_maxlen);
|
||||||
|
m_output += m_ellipsis ? "..." : "";
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
// Add mousebtn command handlers {{{
|
// Add mousebtn command handlers {{{
|
||||||
|
@ -137,7 +137,7 @@ namespace modules {
|
||||||
OUTPUT_ACTION(mousebtn::SCROLL_DOWN);
|
OUTPUT_ACTION(mousebtn::SCROLL_DOWN);
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
m_builder->node(output);
|
m_builder->node(module::get_output());
|
||||||
|
|
||||||
return m_builder->flush();
|
return m_builder->flush();
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ namespace modules {
|
||||||
bool build(builder* builder, string tag) {
|
bool build(builder* builder, string tag) {
|
||||||
if (tag != TAG_OUTPUT)
|
if (tag != TAG_OUTPUT)
|
||||||
return false;
|
return false;
|
||||||
builder->node(m_output);
|
builder->node(string_util::replace_all(m_output, "\n", ""));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue