Merge pull request #4838 from khaneliman/image
fix(image): treat missing interval as once
This commit is contained in:
@ -172,8 +172,6 @@ inline int32_t forkExec(const std::string& cmd, const std::string& output_name)
|
|||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int32_t forkExec(const std::string& cmd) {
|
inline int32_t forkExec(const std::string& cmd) { return forkExec(cmd, ""); }
|
||||||
return forkExec(cmd, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace waybar::util::command
|
} // namespace waybar::util::command
|
||||||
|
|||||||
@ -26,7 +26,8 @@ The *image* module displays an image from a path.
|
|||||||
*interval*: ++
|
*interval*: ++
|
||||||
typeof: integer or float ++
|
typeof: integer or float ++
|
||||||
The interval (in seconds) to re-render the image. ++
|
The interval (in seconds) to re-render the image. ++
|
||||||
Minimum value is 0.001 (1ms). Values smaller than 1ms will be set to 1ms. ++
|
If set to a positive value, the minimum is 0.001 (1ms). Values smaller than 1ms will be set to 1ms. ++
|
||||||
|
Zero or negative values are treated as "once". ++
|
||||||
This is useful if the contents of *path* changes. ++
|
This is useful if the contents of *path* changes. ++
|
||||||
If no *interval* is defined, the image will only be rendered once.
|
If no *interval* is defined, the image will only be rendered once.
|
||||||
|
|
||||||
|
|||||||
@ -237,9 +237,7 @@ void Window::queryActiveWorkspace() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::onEvent(const std::string& ev) {
|
void Window::onEvent(const std::string& ev) { dp.emit(); }
|
||||||
dp.emit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Window::setClass(const std::string& classname, bool enable) {
|
void Window::setClass(const std::string& classname, bool enable) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
|
|||||||
@ -125,9 +125,7 @@ void WindowCount::queryActiveWorkspace() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowCount::onEvent(const std::string& ev) {
|
void WindowCount::onEvent(const std::string& ev) { dp.emit(); }
|
||||||
dp.emit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowCount::setClass(const std::string& classname, bool enable) {
|
void WindowCount::setClass(const std::string& classname, bool enable) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
|
|||||||
@ -14,22 +14,27 @@ waybar::modules::Image::Image(const std::string& id, const Json::Value& config)
|
|||||||
|
|
||||||
size_ = config["size"].asInt();
|
size_ = config["size"].asInt();
|
||||||
|
|
||||||
interval_ = config_["interval"] == "once"
|
const auto once = std::chrono::milliseconds::max();
|
||||||
? std::chrono::milliseconds::max()
|
if (!config_.isMember("interval") || config_["interval"].isNull() ||
|
||||||
: std::chrono::milliseconds(std::max(
|
config_["interval"] == "once") {
|
||||||
1L, // Minimum 1ms due to millisecond precision
|
interval_ = once;
|
||||||
static_cast<long>(
|
} else if (config_["interval"].isNumeric()) {
|
||||||
(config_["interval"].isNumeric() ? config_["interval"].asDouble() : 0) *
|
const auto interval_seconds = config_["interval"].asDouble();
|
||||||
1000)));
|
if (interval_seconds <= 0) {
|
||||||
|
interval_ = once;
|
||||||
|
} else {
|
||||||
|
interval_ =
|
||||||
|
std::chrono::milliseconds(std::max(1L, // Minimum 1ms due to millisecond precision
|
||||||
|
static_cast<long>(interval_seconds * 1000)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
interval_ = once;
|
||||||
|
}
|
||||||
|
|
||||||
if (size_ == 0) {
|
if (size_ == 0) {
|
||||||
size_ = 16;
|
size_ = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interval_.count() == 0) {
|
|
||||||
interval_ = std::chrono::milliseconds::max();
|
|
||||||
}
|
|
||||||
|
|
||||||
delayWorker();
|
delayWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user