mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
refactor(bluetooth): remove interval
and timer thread
The timer thread was always reading the same value from Rfkill state.
This commit is contained in:
parent
ecc32ddd18
commit
52dd3d2446
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "ALabel.hpp"
|
#include "ALabel.hpp"
|
||||||
#include "util/rfkill.hpp"
|
#include "util/rfkill.hpp"
|
||||||
#include "util/sleeper_thread.hpp"
|
|
||||||
|
|
||||||
namespace waybar::modules {
|
namespace waybar::modules {
|
||||||
|
|
||||||
@ -13,8 +12,7 @@ class Bluetooth : public ALabel {
|
|||||||
auto update() -> void;
|
auto update() -> void;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
util::SleeperThread thread_;
|
util::Rfkill rfkill_;
|
||||||
util::Rfkill rfkill_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace waybar::modules
|
} // namespace waybar::modules
|
||||||
|
@ -12,11 +12,6 @@ The *bluetooth* module displays information about the status of the device's blu
|
|||||||
|
|
||||||
Addressed by *bluetooth*
|
Addressed by *bluetooth*
|
||||||
|
|
||||||
*interval*: ++
|
|
||||||
typeof: integer ++
|
|
||||||
default: 60 ++
|
|
||||||
The interval in which the bluetooth state gets updated.
|
|
||||||
|
|
||||||
*format*: ++
|
*format*: ++
|
||||||
typeof: string ++
|
typeof: string ++
|
||||||
default: *{icon}* ++
|
default: *{icon}* ++
|
||||||
@ -88,7 +83,6 @@ Addressed by *bluetooth*
|
|||||||
"bluetooth": {
|
"bluetooth": {
|
||||||
"format": "{icon}",
|
"format": "{icon}",
|
||||||
"format-alt": "bluetooth: {status}",
|
"format-alt": "bluetooth: {status}",
|
||||||
"interval": 30,
|
|
||||||
"format-icons": {
|
"format-icons": {
|
||||||
"enabled": "",
|
"enabled": "",
|
||||||
"disabled": ""
|
"disabled": ""
|
||||||
|
@ -5,13 +5,6 @@
|
|||||||
waybar::modules::Bluetooth::Bluetooth(const std::string& id, const Json::Value& config)
|
waybar::modules::Bluetooth::Bluetooth(const std::string& id, const Json::Value& config)
|
||||||
: ALabel(config, "bluetooth", id, "{icon}", 10), rfkill_{RFKILL_TYPE_BLUETOOTH} {
|
: ALabel(config, "bluetooth", id, "{icon}", 10), rfkill_{RFKILL_TYPE_BLUETOOTH} {
|
||||||
rfkill_.on_update.connect(sigc::hide(sigc::mem_fun(*this, &Bluetooth::update)));
|
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 {
|
auto waybar::modules::Bluetooth::update() -> void {
|
||||||
|
Loading…
Reference in New Issue
Block a user