use `application.process.binary` if `application.name` is not available

This commit is contained in:
Malte Jürgens 2023-01-25 18:47:08 +01:00
parent b4db987217
commit bc317d5531
No known key found for this signature in database
GPG Key ID: D29FBD5F93C0CFC3
1 changed files with 26 additions and 9 deletions

View File

@ -22,7 +22,12 @@ QVector<QString> getTargets() {
if (global.type == pipewire::node::type) { if (global.type == pipewire::node::type) {
auto node = reg.bind<pipewire::node>(global.id); auto node = reg.bind<pipewire::node>(global.id);
auto info = node.info(); auto info = node.info();
auto name = QString::fromStdString(info.props["application.name"]); QString name;
if (info.props.count("application.name"))
name = QString::fromStdString(info.props["application.name"]);
else
name = QString::fromStdString(
info.props["application.process.binary"]);
if (name != "" && !EXCLUDE_TARGETS.contains(name) && if (name != "" && !EXCLUDE_TARGETS.contains(name) &&
!targets.contains(name)) { !targets.contains(name)) {
@ -67,7 +72,11 @@ void start(QString _target) {
continue; continue;
auto &parent = nodes.at(parent_id); auto &parent = nodes.at(parent_id);
auto name = parent.props["application.name"]; std::string name;
if (parent.props.count("application.name"))
name = parent.props["application.name"];
else
name = parent.props["application.process.binary"];
if (name == target || if (name == target ||
(target == "[All Desktop Audio]" && (target == "[All Desktop Audio]" &&
@ -78,8 +87,7 @@ void start(QString _target) {
core.create<pipewire::link_factory>( core.create<pipewire::link_factory>(
{fl ? virt_fl->info().id : virt_fr->info().id, port_id})); {fl ? virt_fl->info().id : virt_fr->info().id, port_id}));
qDebug(virtmicLog) << QString("Link: %1:%2 -> %3") qDebug(virtmicLog) << QString("Link: %1:%2 -> %3")
.arg(QString::fromStdString( .arg(QString::fromStdString(name))
parent.props["application.name"]))
.arg(port_id) .arg(port_id)
.arg(fl ? virt_fl->info().id .arg(fl ? virt_fl->info().id
: virt_fr->info().id) : virt_fr->info().id)
@ -112,11 +120,16 @@ void start(QString _target) {
[&](const pipewire::global &global) { [&](const pipewire::global &global) {
if (global.type == pipewire::node::type) { if (global.type == pipewire::node::type) {
auto node = reg.bind<pipewire::node>(global.id); auto node = reg.bind<pipewire::node>(global.id);
if (!node.info().props.count("application.name")) auto info = node.info();
std::string name;
if (info.props.count("application.name"))
name = info.props["application.name"];
else if (info.props.count("application.process.binary"))
name = info.props["application.process.binary"];
else
return; return;
qDebug(virtmicLog) << QString("Added: %1") qDebug(virtmicLog) << QString("Added: %1")
.arg(QString::fromStdString( .arg(QString::fromStdString(name))
node.info().props["application.name"]))
.toUtf8() .toUtf8()
.data(); .data();
@ -152,9 +165,13 @@ void start(QString _target) {
[&](const std::uint32_t id) { [&](const std::uint32_t id) {
if (nodes.count(id)) { if (nodes.count(id)) {
auto info = nodes.at(id); auto info = nodes.at(id);
std::string name;
if (info.props.count("application.name"))
name = info.props["application.name"];
else
name = info.props["application.process.binary"];
qDebug(virtmicLog) << QString("Removed: %1") qDebug(virtmicLog) << QString("Removed: %1")
.arg(QString::fromStdString( .arg(QString::fromStdString(name))
info.props["application.name"].data()))
.toUtf8() .toUtf8()
.data(); .data();
nodes.erase(id); nodes.erase(id);