From e235f4824571d17fe7ab23a93dec89f9bcdf8553 Mon Sep 17 00:00:00 2001 From: Daan Goossens Date: Sat, 7 May 2022 13:42:27 +0200 Subject: [PATCH] feat: hide module if empty --- man/waybar-bluetooth.5.scd | 1 + src/modules/bluetooth.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/man/waybar-bluetooth.5.scd b/man/waybar-bluetooth.5.scd index f69610d..cafe23c 100644 --- a/man/waybar-bluetooth.5.scd +++ b/man/waybar-bluetooth.5.scd @@ -161,6 +161,7 @@ At the time of writing, the experimental features of BlueZ need to be turned on, "bluetooth": { // "controller": "controller1", // specify the alias of the controller if there are more than 1 on the system "format": " {status}", + "format-disabled": "", // an empty format will hide the module "format-connected": " {num_connections} connected", "tooltip-format": "{controller_alias}\\t{controller_address}", "tooltip-format-connected": "{controller_alias}\\t{controller_address}\\n\\n{device_enumerate}", diff --git a/src/modules/bluetooth.cpp b/src/modules/bluetooth.cpp index 3cc1296..4c77eb2 100644 --- a/src/modules/bluetooth.cpp +++ b/src/modules/bluetooth.cpp @@ -171,6 +171,8 @@ auto waybar::modules::Bluetooth::update() -> void { tooltip_format = config_["tooltip-format"].asString(); } + format_.empty() ? event_box_.hide() : event_box_.show(); + auto update_style_context = [this](const std::string& style_class, bool in_next_state) { if (in_next_state && !label_.get_style_context()->has_class(style_class)) { label_.get_style_context()->add_class(style_class);