fix: lint
This commit is contained in:
@ -99,11 +99,13 @@ void waybar::modules::Wireplumber::updateNodeName(waybar::modules::Wireplumber*
|
|||||||
spdlog::debug("[{}]: Updating '{}' node name to: {}", self->name_, self->type_, self->node_name_);
|
spdlog::debug("[{}]: Updating '{}' node name to: {}", self->name_, self->type_, self->node_name_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void waybar::modules::Wireplumber::updateSourceName(waybar::modules::Wireplumber* self, uint32_t id) {
|
void waybar::modules::Wireplumber::updateSourceName(waybar::modules::Wireplumber* self,
|
||||||
|
uint32_t id) {
|
||||||
spdlog::debug("[{}]: updating source name with node.id {}", self->name_, id);
|
spdlog::debug("[{}]: updating source name with node.id {}", self->name_, id);
|
||||||
|
|
||||||
if (!isValidNodeId(id)) {
|
if (!isValidNodeId(id)) {
|
||||||
spdlog::warn("[{}]: '{}' is not a valid source node ID. Ignoring source name update.", self->name_, id);
|
spdlog::warn("[{}]: '{}' is not a valid source node ID. Ignoring source name update.",
|
||||||
|
self->name_, id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,12 +162,14 @@ void waybar::modules::Wireplumber::updateVolume(waybar::modules::Wireplumber* se
|
|||||||
self->dp.emit();
|
self->dp.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void waybar::modules::Wireplumber::updateSourceVolume(waybar::modules::Wireplumber* self, uint32_t id) {
|
void waybar::modules::Wireplumber::updateSourceVolume(waybar::modules::Wireplumber* self,
|
||||||
|
uint32_t id) {
|
||||||
spdlog::debug("[{}]: updating source volume", self->name_);
|
spdlog::debug("[{}]: updating source volume", self->name_);
|
||||||
GVariant* variant = nullptr;
|
GVariant* variant = nullptr;
|
||||||
|
|
||||||
if (!isValidNodeId(id)) {
|
if (!isValidNodeId(id)) {
|
||||||
spdlog::error("[{}]: '{}' is not a valid source node ID. Ignoring source volume update.", self->name_, id);
|
spdlog::error("[{}]: '{}' is not a valid source node ID. Ignoring source volume update.",
|
||||||
|
self->name_, id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,12 +210,12 @@ void waybar::modules::Wireplumber::onMixerChanged(waybar::modules::Wireplumber*
|
|||||||
const gchar* name = wp_pipewire_object_get_property(WP_PIPEWIRE_OBJECT(node), "node.name");
|
const gchar* name = wp_pipewire_object_get_property(WP_PIPEWIRE_OBJECT(node), "node.name");
|
||||||
|
|
||||||
if (self->node_id_ == id) {
|
if (self->node_id_ == id) {
|
||||||
spdlog::debug("[{}]: (onMixerChanged: {}) - updating sink volume for node: {}",
|
spdlog::debug("[{}]: (onMixerChanged: {}) - updating sink volume for node: {}", self->name_,
|
||||||
self->name_, self->type_, name);
|
self->type_, name);
|
||||||
updateVolume(self, id);
|
updateVolume(self, id);
|
||||||
} else if (self->source_node_id_ == id) {
|
} else if (self->source_node_id_ == id) {
|
||||||
spdlog::debug("[{}]: (onMixerChanged: {}) - updating source volume for node: {}",
|
spdlog::debug("[{}]: (onMixerChanged: {}) - updating source volume for node: {}", self->name_,
|
||||||
self->name_, self->type_, name);
|
self->type_, name);
|
||||||
updateSourceVolume(self, id);
|
updateSourceVolume(self, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -225,17 +229,17 @@ void waybar::modules::Wireplumber::onDefaultNodesApiChanged(waybar::modules::Wir
|
|||||||
|
|
||||||
if (isValidNodeId(defaultNodeId)) {
|
if (isValidNodeId(defaultNodeId)) {
|
||||||
g_autoptr(WpNode) node = static_cast<WpNode*>(
|
g_autoptr(WpNode) node = static_cast<WpNode*>(
|
||||||
wp_object_manager_lookup(self->om_, WP_TYPE_NODE, WP_CONSTRAINT_TYPE_G_PROPERTY, "bound-id",
|
wp_object_manager_lookup(self->om_, WP_TYPE_NODE, WP_CONSTRAINT_TYPE_G_PROPERTY, "bound-id",
|
||||||
"=u", defaultNodeId, nullptr));
|
"=u", defaultNodeId, nullptr));
|
||||||
|
|
||||||
if (node != nullptr) {
|
if (node != nullptr) {
|
||||||
const gchar* defaultNodeName =
|
const gchar* defaultNodeName =
|
||||||
wp_pipewire_object_get_property(WP_PIPEWIRE_OBJECT(node), "node.name");
|
wp_pipewire_object_get_property(WP_PIPEWIRE_OBJECT(node), "node.name");
|
||||||
|
|
||||||
if (g_strcmp0(self->default_node_name_, defaultNodeName) != 0 ||
|
if (g_strcmp0(self->default_node_name_, defaultNodeName) != 0 ||
|
||||||
self->node_id_ != defaultNodeId) {
|
self->node_id_ != defaultNodeId) {
|
||||||
spdlog::debug("[{}]: Default sink changed to -> Node(name: {}, id: {})",
|
spdlog::debug("[{}]: Default sink changed to -> Node(name: {}, id: {})", self->name_,
|
||||||
self->name_, defaultNodeName, defaultNodeId);
|
defaultNodeName, defaultNodeId);
|
||||||
|
|
||||||
g_free(self->default_node_name_);
|
g_free(self->default_node_name_);
|
||||||
self->default_node_name_ = g_strdup(defaultNodeName);
|
self->default_node_name_ = g_strdup(defaultNodeName);
|
||||||
@ -252,17 +256,17 @@ void waybar::modules::Wireplumber::onDefaultNodesApiChanged(waybar::modules::Wir
|
|||||||
|
|
||||||
if (isValidNodeId(defaultSourceId)) {
|
if (isValidNodeId(defaultSourceId)) {
|
||||||
g_autoptr(WpNode) sourceNode = static_cast<WpNode*>(
|
g_autoptr(WpNode) sourceNode = static_cast<WpNode*>(
|
||||||
wp_object_manager_lookup(self->om_, WP_TYPE_NODE, WP_CONSTRAINT_TYPE_G_PROPERTY, "bound-id",
|
wp_object_manager_lookup(self->om_, WP_TYPE_NODE, WP_CONSTRAINT_TYPE_G_PROPERTY, "bound-id",
|
||||||
"=u", defaultSourceId, nullptr));
|
"=u", defaultSourceId, nullptr));
|
||||||
|
|
||||||
if (sourceNode != nullptr) {
|
if (sourceNode != nullptr) {
|
||||||
const gchar* defaultSourceName =
|
const gchar* defaultSourceName =
|
||||||
wp_pipewire_object_get_property(WP_PIPEWIRE_OBJECT(sourceNode), "node.name");
|
wp_pipewire_object_get_property(WP_PIPEWIRE_OBJECT(sourceNode), "node.name");
|
||||||
|
|
||||||
if (g_strcmp0(self->default_source_name_, defaultSourceName) != 0 ||
|
if (g_strcmp0(self->default_source_name_, defaultSourceName) != 0 ||
|
||||||
self->source_node_id_ != defaultSourceId) {
|
self->source_node_id_ != defaultSourceId) {
|
||||||
spdlog::debug("[{}]: Default source changed to -> Node(name: {}, id: {})",
|
spdlog::debug("[{}]: Default source changed to -> Node(name: {}, id: {})", self->name_,
|
||||||
self->name_, defaultSourceName, defaultSourceId);
|
defaultSourceName, defaultSourceId);
|
||||||
|
|
||||||
g_free(self->default_source_name_);
|
g_free(self->default_source_name_);
|
||||||
self->default_source_name_ = g_strdup(defaultSourceName);
|
self->default_source_name_ = g_strdup(defaultSourceName);
|
||||||
@ -299,8 +303,8 @@ void waybar::modules::Wireplumber::onObjectManagerInstalled(waybar::modules::Wir
|
|||||||
// Get default source
|
// Get default source
|
||||||
g_signal_emit_by_name(self->def_nodes_api_, "get-default-configured-node-name", "Audio/Source",
|
g_signal_emit_by_name(self->def_nodes_api_, "get-default-configured-node-name", "Audio/Source",
|
||||||
&self->default_source_name_);
|
&self->default_source_name_);
|
||||||
g_signal_emit_by_name(self->def_nodes_api_, "get-default-node", "Audio/Source", &self->source_node_id_);
|
g_signal_emit_by_name(self->def_nodes_api_, "get-default-node", "Audio/Source",
|
||||||
|
&self->source_node_id_);
|
||||||
|
|
||||||
if (self->default_node_name_ != nullptr) {
|
if (self->default_node_name_ != nullptr) {
|
||||||
spdlog::debug(
|
spdlog::debug(
|
||||||
@ -308,9 +312,8 @@ void waybar::modules::Wireplumber::onObjectManagerInstalled(waybar::modules::Wir
|
|||||||
self->name_, self->type_, self->default_node_name_, self->node_id_);
|
self->name_, self->type_, self->default_node_name_, self->node_id_);
|
||||||
}
|
}
|
||||||
if (self->default_source_name_ != nullptr) {
|
if (self->default_source_name_ != nullptr) {
|
||||||
spdlog::debug(
|
spdlog::debug("[{}]: default source: {} (id: {})", self->name_, self->default_source_name_,
|
||||||
"[{}]: default source: {} (id: {})",
|
self->source_node_id_);
|
||||||
self->name_, self->default_source_name_, self->source_node_id_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateVolume(self, self->node_id_);
|
updateVolume(self, self->node_id_);
|
||||||
@ -459,16 +462,13 @@ auto waybar::modules::Wireplumber::update() -> void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Format the source string with actual volume
|
// Format the source string with actual volume
|
||||||
std::string formatted_source = fmt::format(fmt::runtime(format_source),
|
std::string formatted_source =
|
||||||
fmt::arg("volume", source_vol));
|
fmt::format(fmt::runtime(format_source), fmt::arg("volume", source_vol));
|
||||||
|
|
||||||
std::string markup = fmt::format(fmt::runtime(format),
|
std::string markup =
|
||||||
fmt::arg("node_name", node_name_),
|
fmt::format(fmt::runtime(format), fmt::arg("node_name", node_name_), fmt::arg("volume", vol),
|
||||||
fmt::arg("volume", vol),
|
fmt::arg("icon", getIcon(vol)), fmt::arg("format_source", formatted_source),
|
||||||
fmt::arg("icon", getIcon(vol)),
|
fmt::arg("source_volume", source_vol), fmt::arg("source_desc", source_name_));
|
||||||
fmt::arg("format_source", formatted_source),
|
|
||||||
fmt::arg("source_volume", source_vol),
|
|
||||||
fmt::arg("source_desc", source_name_));
|
|
||||||
label_.set_markup(markup);
|
label_.set_markup(markup);
|
||||||
|
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
@ -477,13 +477,10 @@ auto waybar::modules::Wireplumber::update() -> void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!tooltipFormat.empty()) {
|
if (!tooltipFormat.empty()) {
|
||||||
label_.set_tooltip_text(fmt::format(fmt::runtime(tooltipFormat),
|
label_.set_tooltip_text(fmt::format(
|
||||||
fmt::arg("node_name", node_name_),
|
fmt::runtime(tooltipFormat), fmt::arg("node_name", node_name_), fmt::arg("volume", vol),
|
||||||
fmt::arg("volume", vol),
|
fmt::arg("icon", getIcon(vol)), fmt::arg("format_source", formatted_source),
|
||||||
fmt::arg("icon", getIcon(vol)),
|
fmt::arg("source_volume", source_vol), fmt::arg("source_desc", source_name_)));
|
||||||
fmt::arg("format_source", formatted_source),
|
|
||||||
fmt::arg("source_volume", source_vol),
|
|
||||||
fmt::arg("source_desc", source_name_)));
|
|
||||||
} else {
|
} else {
|
||||||
label_.set_tooltip_text(node_name_);
|
label_.set_tooltip_text(node_name_);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user