Add format_silent to cava module

This commit is contained in:
Sonter 2024-08-14 11:34:28 +03:00
parent 21906f07b3
commit 62cb61c670
2 changed files with 3 additions and 0 deletions

View File

@ -39,6 +39,7 @@ class Cava final : public ALabel {
std::chrono::seconds suspend_silence_delay_{0}; std::chrono::seconds suspend_silence_delay_{0};
bool silence_{false}; bool silence_{false};
bool hide_on_silence_{false}; bool hide_on_silence_{false};
std::string format_silent_{""};
int sleep_counter_{0}; int sleep_counter_{0};
// Cava method // Cava method
void pause_resume(); void pause_resume();

View File

@ -59,6 +59,7 @@ waybar::modules::Cava::Cava(const std::string& id, const Json::Value& config)
if (config_["input_delay"].isInt()) if (config_["input_delay"].isInt())
fetch_input_delay_ = std::chrono::seconds(config_["input_delay"].asInt()); fetch_input_delay_ = std::chrono::seconds(config_["input_delay"].asInt());
if (config_["hide_on_silence"].isBool()) hide_on_silence_ = config_["hide_on_silence"].asBool(); if (config_["hide_on_silence"].isBool()) hide_on_silence_ = config_["hide_on_silence"].asBool();
if (config_["format_silent"].isString()) format_silent_ = config_["format_silent"].asString();
// Make cava parameters configuration // Make cava parameters configuration
plan_ = new cava::cava_plan{}; plan_ = new cava::cava_plan{};
@ -176,6 +177,7 @@ auto waybar::modules::Cava::update() -> void {
} else { } else {
upThreadDelay(frame_time_milsec_, suspend_silence_delay_); upThreadDelay(frame_time_milsec_, suspend_silence_delay_);
if (hide_on_silence_) label_.hide(); if (hide_on_silence_) label_.hide();
else if (config_["format_silent"].isString()) label_.set_markup(format_silent_);
} }
} }