refactor(bluetooth): remove interval and timer thread

The timer thread was always reading the same value from Rfkill state.
This commit is contained in:
Aleksei Bavshin
2021-02-02 20:10:27 -08:00
parent ecc32ddd18
commit 52dd3d2446
3 changed files with 1 additions and 16 deletions

View File

@ -5,13 +5,6 @@
waybar::modules::Bluetooth::Bluetooth(const std::string& id, const Json::Value& config)
: ALabel(config, "bluetooth", id, "{icon}", 10), rfkill_{RFKILL_TYPE_BLUETOOTH} {
rfkill_.on_update.connect(sigc::hide(sigc::mem_fun(*this, &Bluetooth::update)));
thread_ = [this] {
auto now = std::chrono::system_clock::now();
auto timeout = std::chrono::floor<std::chrono::seconds>(now + interval_);
auto diff = std::chrono::seconds(timeout.time_since_epoch().count() % interval_.count());
thread_.sleep_until(timeout - diff);
dp.emit();
};
}
auto waybar::modules::Bluetooth::update() -> void {