From 52dd3d2446a99ff822ae4fd913bdab3dc2c06d1c Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Tue, 2 Feb 2021 20:10:27 -0800 Subject: [PATCH] refactor(bluetooth): remove `interval` and timer thread The timer thread was always reading the same value from Rfkill state. --- include/modules/bluetooth.hpp | 4 +--- man/waybar-bluetooth.5.scd | 6 ------ src/modules/bluetooth.cpp | 7 ------- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/include/modules/bluetooth.hpp b/include/modules/bluetooth.hpp index 4d7b7c84..87845c95 100644 --- a/include/modules/bluetooth.hpp +++ b/include/modules/bluetooth.hpp @@ -2,7 +2,6 @@ #include "ALabel.hpp" #include "util/rfkill.hpp" -#include "util/sleeper_thread.hpp" namespace waybar::modules { @@ -13,8 +12,7 @@ class Bluetooth : public ALabel { auto update() -> void; private: - util::SleeperThread thread_; - util::Rfkill rfkill_; + util::Rfkill rfkill_; }; } // namespace waybar::modules diff --git a/man/waybar-bluetooth.5.scd b/man/waybar-bluetooth.5.scd index 0cd9386a..d4ecb1d1 100644 --- a/man/waybar-bluetooth.5.scd +++ b/man/waybar-bluetooth.5.scd @@ -12,11 +12,6 @@ The *bluetooth* module displays information about the status of the device's blu Addressed by *bluetooth* -*interval*: ++ - typeof: integer ++ - default: 60 ++ - The interval in which the bluetooth state gets updated. - *format*: ++ typeof: string ++ default: *{icon}* ++ @@ -88,7 +83,6 @@ Addressed by *bluetooth* "bluetooth": { "format": "{icon}", "format-alt": "bluetooth: {status}", - "interval": 30, "format-icons": { "enabled": "", "disabled": "" diff --git a/src/modules/bluetooth.cpp b/src/modules/bluetooth.cpp index 0df404d3..88526845 100644 --- a/src/modules/bluetooth.cpp +++ b/src/modules/bluetooth.cpp @@ -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(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 {