Skip to content

Commit

Permalink
app_info: showing the application.process.binary if the other name ta…
Browse files Browse the repository at this point in the history
…gs are empty
  • Loading branch information
wwmm committed Dec 12, 2023
1 parent 457ed9e commit 50aaa86
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
4 changes: 4 additions & 0 deletions include/pipe_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ struct NodeInfo {

std::string media_role;

std::string app_name;

std::string app_process_binary;

std::string app_icon_name;

std::string media_icon_name;
Expand Down
28 changes: 25 additions & 3 deletions src/app_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ auto app_is_blocklisted(AppInfo* self, const std::string& name) -> bool {
auto get_app_icon_name(const NodeInfo& node_info) -> std::string {
// map to handle cases where PipeWire does not set icon name string or app name equal to icon name.

constexpr auto icon_map = std::to_array<std::pair<const char*, const char*>>(
{{"chromium-browser", "chromium"}, {"firefox", "firefox"}, {"nightly","firefox-nightly"}, {"obs", "com.obsproject.Studio"}});
constexpr auto icon_map = std::to_array<std::pair<const char*, const char*>>({{"chromium-browser", "chromium"},
{"firefox", "firefox"},
{"nightly", "firefox-nightly"},
{"obs", "com.obsproject.Studio"}});

std::string icon_name;

Expand Down Expand Up @@ -225,7 +227,27 @@ void update(AppInfo* self, const NodeInfo node_info) {

self->data->info = node_info;

gtk_label_set_text(self->app_name, node_info.name.c_str());
std::string app_name = node_info.app_name;

auto isspace = [](std::string_view a) { return std::ranges::all_of(a, [](auto c) { return std::isspace(c); }); };

if (app_name.empty() || isspace(app_name)) {
app_name = node_info.name;
}

if (app_name.empty() || isspace(app_name)) {
app_name = node_info.app_process_binary;
}

if (app_name.empty() || isspace(app_name)) {
app_name = node_info.app_process_binary;
}

if (app_name.empty()) {
app_name = _("Undefined");
}

gtk_label_set_text(self->app_name, app_name.c_str());
gtk_label_set_text(self->media_name, node_info.media_name.c_str());
gtk_label_set_text(self->format, node_info.format.c_str());
gtk_label_set_text(
Expand Down
22 changes: 19 additions & 3 deletions src/pipe_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,24 @@ void on_node_info(void* object, const struct pw_node_info* info) {
}
}

// spa_dict_get_string(props, PW_KEY_APP_PROCESS_BINARY, app_process_binary);

if (const auto* app_name = spa_dict_lookup(info->props, PW_KEY_APP_NAME)) {
if (app_name != nd->nd_info->app_name) {
nd->nd_info->app_name = app_name;

app_info_ui_changed = true;
}
}

if (const auto* app_process_binary = spa_dict_lookup(info->props, PW_KEY_APP_PROCESS_BINARY)) {
if (app_process_binary != nd->nd_info->app_process_binary) {
nd->nd_info->app_process_binary = app_process_binary;

app_info_ui_changed = true;
}
}

if (const auto* app_icon_name = spa_dict_lookup(info->props, PW_KEY_APP_ICON_NAME)) {
if (app_icon_name != nd->nd_info->app_icon_name) {
nd->nd_info->app_icon_name = app_icon_name;
Expand Down Expand Up @@ -1061,9 +1079,7 @@ void on_registry_global(void* data,

std::string node_name;

if (!spa_dict_get_string(props, PW_KEY_NODE_NAME, node_name) || node_name.empty()) {
node_name = "Undefined Name";
}
spa_dict_get_string(props, PW_KEY_NODE_NAME, node_name);

// At least for now I do not think there is a point in showing the spectrum adn the output level filters in menus

Expand Down

0 comments on commit 50aaa86

Please sign in to comment.