Skip to content

Commit

Permalink
Merge pull request #3362 from lukasfink1/bt-dyn-controller-pr
Browse files Browse the repository at this point in the history
Fix device list not being updated on selecting new bluetooth controller
  • Loading branch information
Alexays committed Jun 14, 2024
2 parents 3f49725 + 0df3c84 commit 9ba5825
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/modules/bluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,25 @@ auto waybar::modules::Bluetooth::onObjectAdded(GDBusObjectManager* manager,
auto waybar::modules::Bluetooth::onObjectRemoved(GDBusObjectManager* manager,
GDBusObject* object,
gpointer user_data) -> void {
GDBusProxy* proxy_controller =
G_DBUS_PROXY(g_dbus_object_get_interface(object, "org.bluez.Adapter1"));
Bluetooth* bt = static_cast<Bluetooth*>(user_data);
GDBusProxy* proxy_controller;

if (!bt->cur_controller_.has_value()) {
return;
}

proxy_controller = G_DBUS_PROXY(g_dbus_object_get_interface(object, "org.bluez.Adapter1"));

if (proxy_controller != NULL) {

std::string object_path = g_dbus_object_get_object_path(object);
Bluetooth* bt = static_cast<Bluetooth*>(user_data);

if (object_path == bt->cur_controller_->path) {
bt->cur_controller_ = bt->findCurController();
if (bt->cur_controller_.has_value()) {
bt->connected_devices_.clear();
bt->findConnectedDevices(bt->cur_controller_->path, bt->connected_devices_);
}
bt->dp.emit();
}

Expand Down

0 comments on commit 9ba5825

Please sign in to comment.