Merge pull request #3523 from S0nter/master
cava: Add format_silent option and css triggers
This commit is contained in:
commit
b5395f4e6f
|
@ -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();
|
||||||
|
|
|
@ -64,6 +64,10 @@ libcava lives in:
|
||||||
:[ bool
|
:[ bool
|
||||||
:[ false
|
:[ false
|
||||||
:[ Hides the widget if no input (after sleep_timer elapsed)
|
:[ Hides the widget if no input (after sleep_timer elapsed)
|
||||||
|
|[ *format_silent*
|
||||||
|
:[ string
|
||||||
|
:[
|
||||||
|
:[ Widget's text after sleep_timer elapsed (hide_on_silence has to be false)
|
||||||
|[ *method*
|
|[ *method*
|
||||||
:[ string
|
:[ string
|
||||||
:[ pulse
|
:[ pulse
|
||||||
|
@ -196,3 +200,8 @@ In case when cava releases new version and you're wanna get it, it should be rai
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
# STYLE
|
||||||
|
|
||||||
|
- *#cava*
|
||||||
|
- *#cava.silent* Applied after no sound has been detected for sleep_timer seconds
|
||||||
|
- *#cava.updated* Applied when a new frame is shown
|
||||||
|
|
|
@ -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{};
|
||||||
|
|
||||||
|
@ -172,10 +173,17 @@ auto waybar::modules::Cava::update() -> void {
|
||||||
label_.set_markup(text_);
|
label_.set_markup(text_);
|
||||||
label_.show();
|
label_.show();
|
||||||
ALabel::update();
|
ALabel::update();
|
||||||
|
label_.get_style_context()->add_class("updated");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
label_.get_style_context()->remove_class("silent");
|
||||||
} 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_);
|
||||||
|
|
||||||
|
label_.get_style_context()->add_class("silent");
|
||||||
|
label_.get_style_context()->remove_class("updated");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue