Add format-bluetooth support to wireplumber module
This commit is contained in:
+32
-12
@@ -14,16 +14,16 @@ waybar::modules::Wireplumber::Wireplumber(const std::string& id, const Json::Val
|
||||
mixer_api_(nullptr),
|
||||
def_nodes_api_(nullptr),
|
||||
default_node_name_(nullptr),
|
||||
default_source_name_(nullptr),
|
||||
pending_plugins_(0),
|
||||
muted_(false),
|
||||
source_muted_(false),
|
||||
volume_(0.0),
|
||||
source_volume_(0.0),
|
||||
min_step_(0.0),
|
||||
node_id_(0),
|
||||
type_(nullptr),
|
||||
source_node_id_(0),
|
||||
type_(nullptr) {
|
||||
source_muted_(false),
|
||||
source_volume_(0.0),
|
||||
default_source_name_(nullptr) {
|
||||
waybar::modules::Wireplumber::modules.push_back(this);
|
||||
|
||||
wp_init(WP_INIT_PIPEWIRE);
|
||||
@@ -418,10 +418,33 @@ void waybar::modules::Wireplumber::asyncLoadRequiredApiModules() {
|
||||
auto waybar::modules::Wireplumber::update() -> void {
|
||||
auto format = format_;
|
||||
std::string tooltipFormat;
|
||||
std::string format_name = "format";
|
||||
|
||||
// Handle sink bluetooth state
|
||||
const std::string name = default_node_name_ != nullptr ? default_node_name_ : "";
|
||||
|
||||
auto bt = name.find("bluez") != std::string::npos || name.find("a2dp-sink") != std::string::npos;
|
||||
if (bt) {
|
||||
// format =
|
||||
// config_["format-bluetooth"].isString() ? config_["format-bluetooth"].asString() : format;
|
||||
format_name += "-bluetooth";
|
||||
label_.get_style_context()->add_class("bluetooth");
|
||||
} else {
|
||||
label_.get_style_context()->remove_class("bluetooth");
|
||||
}
|
||||
|
||||
// Handle sink mute state
|
||||
if (muted_) {
|
||||
format = config_["format-muted"].isString() ? config_["format-muted"].asString() : format;
|
||||
// if (bt)
|
||||
// format = config_["format-bluetooth-muted"].isString()
|
||||
// ? config_["format-bluetooth-muted"].asString()
|
||||
// : format;
|
||||
// else
|
||||
// format = config_["format-muted"].isString() ? config_["format-muted"].asString() : format;
|
||||
// Check muted bluetooth format exists, otherwise fall back to default muted format.
|
||||
if (format_name != "format" && !config_[format_name + "-muted"].isString())
|
||||
format_name = "format";
|
||||
format_name += "-muted";
|
||||
label_.get_style_context()->add_class("muted");
|
||||
label_.get_style_context()->add_class("sink-muted");
|
||||
} else {
|
||||
@@ -441,13 +464,10 @@ auto waybar::modules::Wireplumber::update() -> void {
|
||||
|
||||
// Get the state and apply state-specific format if available
|
||||
auto state = getState(vol);
|
||||
if (!state.empty()) {
|
||||
std::string format_name = muted_ ? "format-muted" : "format";
|
||||
std::string state_format_name = format_name + "-" + state;
|
||||
if (config_[state_format_name].isString()) {
|
||||
format = config_[state_format_name].asString();
|
||||
}
|
||||
}
|
||||
if (!state.empty() && config_[format_name + "-" + state].isString())
|
||||
format = config_[format_name + "-" + state].asString();
|
||||
else if (config_[format_name].isString())
|
||||
format = config_[format_name].asString();
|
||||
|
||||
// Prepare source format string (similar to PulseAudio)
|
||||
std::string format_source = "{volume}%";
|
||||
|
||||
Reference in New Issue
Block a user