Files
Waybar/src/util/pipewire/privacy_node_info.cpp
T
Erik Reider eeb7bc702e Added GeoClue2 privacy item
Rebased onto current master and fixed the privacy module build:
- privacy_item.hpp no longer includes privacy.hpp (it does not use the
  Privacy class); this broke the circular include that left PrivacyItem
  undeclared when privacy.hpp was reached first from privacy_item.cpp.
- privacy_item.cpp now includes gtkmm/label.h explicitly, since Gtk::Label
  was previously only pulled in transitively via privacy.hpp.
2026-07-04 01:42:35 +02:00

59 lines
1.9 KiB
C++

#include "util/pipewire/privacy_node_info.hpp"
namespace waybar::util::PipewireBackend {
std::string PWPrivacyNodeInfo::getName() {
const std::vector<std::string*> names{&application_name, &node_name};
std::string name = "Unknown Application";
for (const auto& item : names) {
if (item != nullptr && !item->empty()) {
name = *item;
name[0] = toupper(name[0]);
break;
}
}
return name;
}
std::string PWPrivacyNodeInfo::getIconName() {
const std::vector<std::string*> names{&application_icon_name, &pipewire_access_portal_app_id,
&application_name, &node_name};
std::string name = "application-x-executable-symbolic";
for (const auto& item : names) {
if (item != nullptr && !item->empty() && DefaultGtkIconThemeWrapper::has_icon(*item)) {
return *item;
}
}
return name;
}
void PWPrivacyNodeInfo::handleProxyEventDestroy() {
spa_hook_remove(&proxy_listener);
spa_hook_remove(&object_listener);
}
void PWPrivacyNodeInfo::handleNodeEventInfo(const struct pw_node_info* info) {
state = info->state;
const struct spa_dict_item* item;
spa_dict_for_each(item, info->props) {
if (strcmp(item->key, PW_KEY_CLIENT_ID) == 0) {
client_id = strtoul(item->value, nullptr, 10);
} else if (strcmp(item->key, PW_KEY_MEDIA_NAME) == 0) {
media_name = item->value;
} else if (strcmp(item->key, PW_KEY_NODE_NAME) == 0) {
node_name = item->value;
} else if (strcmp(item->key, PW_KEY_APP_NAME) == 0) {
application_name = item->value;
} else if (strcmp(item->key, "pipewire.access.portal.app_id") == 0) {
pipewire_access_portal_app_id = item->value;
} else if (strcmp(item->key, PW_KEY_APP_ICON_NAME) == 0) {
application_icon_name = item->value;
} else if (strcmp(item->key, "stream.monitor") == 0) {
is_monitor = strcmp(item->value, "true") == 0;
}
}
}
} // namespace waybar::util::PipewireBackend