fix(script): Receiving multiple lines rapidly only displays first line (#3119)
Fixes #3117
This commit is contained in:
parent
ab583b08cd
commit
81ea16931e
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- `custom/script`: When a script with `tail = true` received multiple lines quickly, only the first would get displayed ([`#3117`](https://github.com/polybar/polybar/issues/3117), [`#3119`](https://github.com/polybar/polybar/pull/3119)) by [@Isak05](https://github.com/Isak05)
|
||||||
- Token min-length calculations would behave differently when non-ASCII characters appear in the token ([`#3074`](https://github.com/polybar/polybar/issues/3074), [`#3087`](https://github.com/polybar/polybar/pull/3087)) by [@nklloyd](https://github.com/nklloyd)
|
- Token min-length calculations would behave differently when non-ASCII characters appear in the token ([`#3074`](https://github.com/polybar/polybar/issues/3074), [`#3087`](https://github.com/polybar/polybar/pull/3087)) by [@nklloyd](https://github.com/nklloyd)
|
||||||
- i3: Fix duplicated rendering for non-full-width bars ([`#3091`](https://github.com/polybar/polybar/pull/3091), [`#3060`](https://github.com/polybar/polybar/issues/3060))
|
- i3: Fix duplicated rendering for non-full-width bars ([`#3091`](https://github.com/polybar/polybar/pull/3091), [`#3060`](https://github.com/polybar/polybar/issues/3060))
|
||||||
- `internal/backlight`: Module could display the literal `%percentage%` token if the backlight reports a value of 0 at startup ([`#3081`](https://github.com/polybar/polybar/pull/3081)) by [@unclechu](https://github.com/unclechu)
|
- `internal/backlight`: Module could display the literal `%percentage%` token if the backlight reports a value of 0 at startup ([`#3081`](https://github.com/polybar/polybar/pull/3081)) by [@unclechu](https://github.com/unclechu)
|
||||||
|
@ -119,7 +119,7 @@ namespace modules {
|
|||||||
|
|
||||||
template <typename Impl>
|
template <typename Impl>
|
||||||
string module<Impl>::contents() {
|
string module<Impl>::contents() {
|
||||||
if (m_changed) {
|
if (m_changed.exchange(false)) {
|
||||||
m_log.info("%s: Rebuilding cache", name());
|
m_log.info("%s: Rebuilding cache", name());
|
||||||
m_cache = CAST_MOD(Impl)->get_output();
|
m_cache = CAST_MOD(Impl)->get_output();
|
||||||
// Make sure builder is really empty
|
// Make sure builder is really empty
|
||||||
@ -129,7 +129,6 @@ namespace modules {
|
|||||||
m_builder->control(tags::controltag::R);
|
m_builder->control(tags::controltag::R);
|
||||||
m_cache += m_builder->flush();
|
m_cache += m_builder->flush();
|
||||||
}
|
}
|
||||||
m_changed = false;
|
|
||||||
}
|
}
|
||||||
return m_cache;
|
return m_cache;
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,7 @@ class command<output_policy::REDIRECTED> : private command<output_policy::IGNORE
|
|||||||
|
|
||||||
void tail(std::function<void(string)> cb);
|
void tail(std::function<void(string)> cb);
|
||||||
string readline();
|
string readline();
|
||||||
|
bool wait_for_data(int timeout_ms);
|
||||||
|
|
||||||
int get_stdout(int c);
|
int get_stdout(int c);
|
||||||
int get_stdin(int c);
|
int get_stdin(int c);
|
||||||
|
@ -155,7 +155,7 @@ script_runner::interval script_runner::run_tail() {
|
|||||||
assert(fd != -1);
|
assert(fd != -1);
|
||||||
|
|
||||||
while (!m_stopping && cmd.is_running() && !io_util::poll(fd, POLLHUP, 0)) {
|
while (!m_stopping && cmd.is_running() && !io_util::poll(fd, POLLHUP, 0)) {
|
||||||
if (io_util::poll_read(fd, 250)) {
|
if (cmd.wait_for_data(250)) {
|
||||||
auto changed = set_output(cmd.readline());
|
auto changed = set_output(cmd.readline());
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
@ -201,6 +201,14 @@ string command<output_policy::REDIRECTED>::readline() {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait until there is data in the output stream or until timeout_ms milliseconds
|
||||||
|
*/
|
||||||
|
bool command<output_policy::REDIRECTED>::wait_for_data(int timeout_ms) {
|
||||||
|
return (m_stdout_reader && m_stdout_reader->rdbuf()->in_avail() > 0) ||
|
||||||
|
io_util::poll_read(get_stdout(PIPE_READ), timeout_ms);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get command output channel
|
* Get command output channel
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user