refactor(bluetooth): remove `interval` and timer thread
The timer thread was always reading the same value from Rfkill state.pull/1015/head
parent
ecc32ddd18
commit
52dd3d2446
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "ALabel.hpp"
|
||||
#include "util/rfkill.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
|
@ -13,7 +12,6 @@ class Bluetooth : public ALabel {
|
|||
auto update() -> void;
|
||||
|
||||
private:
|
||||
util::SleeperThread thread_;
|
||||
util::Rfkill rfkill_;
|
||||
};
|
||||
|
||||
|
|
|
@ -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": ""
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue