From 1eb077779943a77f6a249fb2049ca74b111ea933 Mon Sep 17 00:00:00 2001 From: Joerg Weislogel Date: Sat, 7 Oct 2023 12:50:24 +0200 Subject: [PATCH 1/2] add function to cava module to hide on silence --- include/modules/cava.hpp | 1 + src/modules/cava.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/modules/cava.hpp b/include/modules/cava.hpp index d4da2b77..76a459c0 100644 --- a/include/modules/cava.hpp +++ b/include/modules/cava.hpp @@ -36,6 +36,7 @@ class Cava final : public ALabel { std::chrono::seconds fetch_input_delay_{4}; std::chrono::seconds suspend_silence_delay_{0}; bool silence_{false}; + bool hide_on_silence_{false}; int sleep_counter_{0}; // Cava method void pause_resume(); diff --git a/src/modules/cava.cpp b/src/modules/cava.cpp index be9bef4e..6ef6bf0b 100644 --- a/src/modules/cava.cpp +++ b/src/modules/cava.cpp @@ -64,6 +64,7 @@ waybar::modules::Cava::Cava(const std::string& id, const Json::Value& config) prm_.noise_reduction = config_["noise_reduction"].asDouble(); if (config_["input_delay"].isInt()) fetch_input_delay_ = std::chrono::seconds(config_["input_delay"].asInt()); + if (config_["hide_on_silence"].isBool()) hide_on_silence_ = config_["hide_on_silence"].asBool(); // Make cava parameters configuration plan_ = new cava_plan{}; @@ -174,10 +175,13 @@ auto waybar::modules::Cava::update() -> void { } label_.set_markup(text_); + label_.show(); ALabel::update(); } - } else + } else { upThreadDelay(frame_time_milsec_, suspend_silence_delay_); + if (hide_on_silence_) label_.hide(); + } } auto waybar::modules::Cava::doAction(const std::string& name) -> void { From b2e88347b32993df7fe9bed38088d94f9f8f5624 Mon Sep 17 00:00:00 2001 From: Joerg Weislogel Date: Mon, 9 Oct 2023 17:05:12 +0200 Subject: [PATCH 2/2] added description for configuration option hide-on-silence in man file --- man/waybar-cava.5.scd | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/man/waybar-cava.5.scd b/man/waybar-cava.5.scd index 5d62572e..88e736e5 100644 --- a/man/waybar-cava.5.scd +++ b/man/waybar-cava.5.scd @@ -35,7 +35,7 @@ libcava lives in: |[ *framerate* :[ integer :[ 30 -:[ rames per second. Is used as a replacement for *interval* +:[ Frames per second. Is used as a replacement for *interval* |[ *autosens* :[ integer :[ 1 @@ -60,6 +60,10 @@ libcava lives in: :[ integer :[ 5 :[ Seconds with no input before cava main thread goes to sleep mode +|[ *hide_on_silence* +:[ bool +:[ false +:[ Hides the widget if no input (after sleep_timer elapsed) |[ *method* :[ string :[ pulse