Merge pull request #4334 from theoratkin/master
feat(mpd): add playing-interval option
This commit is contained in:
@@ -23,6 +23,8 @@ waybar::modules::MPD::MPD(const std::string& id, const Json::Value& config)
|
||||
port_(config_["port"].isUInt() ? config["port"].asUInt() : 0),
|
||||
password_(config_["password"].empty() ? "" : config_["password"].asString()),
|
||||
timeout_(config_["timeout"].isUInt() ? config_["timeout"].asUInt() * 1'000 : 30'000),
|
||||
playing_interval_(config_["playing-interval"].isUInt() ? config_["playing-interval"].asUInt()
|
||||
: 1'000),
|
||||
connection_(nullptr, &mpd_connection_free),
|
||||
status_(nullptr, &mpd_status_free),
|
||||
song_(nullptr, &mpd_song_free),
|
||||
@@ -35,6 +37,10 @@ waybar::modules::MPD::MPD(const std::string& id, const Json::Value& config)
|
||||
spdlog::warn("{}: `timeout` configuration should be an unsigned int", module_name_);
|
||||
}
|
||||
|
||||
if (!config_["playing-interval"].isNull() && !config_["playing-interval"].isUInt()) {
|
||||
spdlog::warn("{}: `playing-interval` configuration should be an unsigned int", module_name_);
|
||||
}
|
||||
|
||||
if (!config["server"].isNull()) {
|
||||
if (!config_["server"].isString()) {
|
||||
spdlog::warn("{}:`server` configuration should be a string", module_name_);
|
||||
|
||||
@@ -115,7 +115,7 @@ bool Idle::on_io(Glib::IOCondition const&) {
|
||||
void Playing::entry() noexcept {
|
||||
timer();
|
||||
idle();
|
||||
spdlog::debug("mpd: Playing: enabled 1 second periodic timer.");
|
||||
spdlog::debug("mpd: Playing: enabled {}ms periodic timer.", ctx_->playing_interval());
|
||||
}
|
||||
|
||||
void Playing::exit() noexcept {
|
||||
@@ -126,7 +126,7 @@ void Playing::exit() noexcept {
|
||||
|
||||
if (timer_connection_.connected()) {
|
||||
timer_connection_.disconnect();
|
||||
spdlog::debug("mpd: Playing: disabled 1 second periodic timer.");
|
||||
spdlog::debug("mpd: Playing: disabled {}ms periodic timer.", ctx_->playing_interval());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ void Playing::timer() noexcept {
|
||||
}
|
||||
|
||||
sigc::slot<bool> timer_slot = sigc::mem_fun(*this, &Playing::on_timer);
|
||||
timer_connection_ = Glib::signal_timeout().connect_seconds(timer_slot, 1);
|
||||
timer_connection_ = Glib::signal_timeout().connect(timer_slot, ctx_->playing_interval());
|
||||
}
|
||||
|
||||
void Playing::idle() noexcept {
|
||||
|
||||
Reference in New Issue
Block a user