diff --git a/src/modules/sni/host.cpp b/src/modules/sni/host.cpp index b9204bcc..62a68a2e 100644 --- a/src/modules/sni/host.cpp +++ b/src/modules/sni/host.cpp @@ -130,8 +130,13 @@ std::tuple Host::getBusNameAndObjectPath(const std::st void Host::addRegisteredItem(std::string service) { auto [bus_name, object_path] = getBusNameAndObjectPath(service); - items_.emplace_back(new Item(bus_name, object_path, config_)); - on_add_(items_.back()); + auto it = std::find_if(items_.begin(), items_.end(), [&bus_name, &object_path](const auto& item) { + return bus_name == item->bus_name && object_path == item->object_path; + }); + if (it == items_.end()) { + items_.emplace_back(new Item(bus_name, object_path, config_)); + on_add_(items_.back()); + } } -} \ No newline at end of file +} // namespace waybar::modules::SNI \ No newline at end of file diff --git a/src/modules/sni/watcher.cpp b/src/modules/sni/watcher.cpp index 3937d15a..42cfe2a3 100644 --- a/src/modules/sni/watcher.cpp +++ b/src/modules/sni/watcher.cpp @@ -28,7 +28,9 @@ Watcher::~Watcher() { g_slist_free_full(items_, gfWatchFree); items_ = nullptr; } - g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(watcher_)); + auto iface = G_DBUS_INTERFACE_SKELETON(watcher_); + auto conn = g_dbus_interface_skeleton_get_connection(iface); + g_dbus_interface_skeleton_unexport_from_connection(iface, conn); } void Watcher::busAcquired(const Glib::RefPtr& conn, Glib::ustring name) {