mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
add rudimentary bluetooth module functionality
This commit is contained in:
29
src/modules/bluetooth.cpp
Normal file
29
src/modules/bluetooth.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include "modules/bluetooth.hpp"
|
||||
#include "util/rfkill.hpp"
|
||||
#include <linux/rfkill.h>
|
||||
|
||||
waybar::modules::Bluetooth::Bluetooth(const std::string& id, const Json::Value& config)
|
||||
: ALabel(config, "bluetooth", id, "{status}", 10) {
|
||||
dp.emit();
|
||||
}
|
||||
|
||||
auto waybar::modules::Bluetooth::update() -> void {
|
||||
auto text = "enabled";
|
||||
if (waybar::util::isDisabled(RFKILL_TYPE_BLUETOOTH)) {
|
||||
text = "disabled";
|
||||
} else {
|
||||
text = "enabled";
|
||||
}
|
||||
|
||||
label_.set_markup(text);
|
||||
|
||||
if (tooltipEnabled()) {
|
||||
if (config_["tooltip-format"].isString()) {
|
||||
auto tooltip_format = config_["tooltip-format"].asString();
|
||||
auto tooltip_text = fmt::format(tooltip_format, localtime);
|
||||
label_.set_tooltip_text(tooltip_text);
|
||||
} else {
|
||||
label_.set_tooltip_text(text);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user