From bc317d5531ce3b2c4e5372ec19b24a32be09a9ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20J=C3=BCrgens?= Date: Wed, 25 Jan 2023 18:47:08 +0100 Subject: [PATCH] use `application.process.binary` if `application.name` is not available --- src/virtmic.cpp | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/virtmic.cpp b/src/virtmic.cpp index ba6d1fc..5ec2e5a 100644 --- a/src/virtmic.cpp +++ b/src/virtmic.cpp @@ -22,7 +22,12 @@ QVector getTargets() { if (global.type == pipewire::node::type) { auto node = reg.bind(global.id); 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) && !targets.contains(name)) { @@ -67,7 +72,11 @@ void start(QString _target) { continue; 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 || (target == "[All Desktop Audio]" && @@ -78,8 +87,7 @@ void start(QString _target) { core.create( {fl ? virt_fl->info().id : virt_fr->info().id, port_id})); qDebug(virtmicLog) << QString("Link: %1:%2 -> %3") - .arg(QString::fromStdString( - parent.props["application.name"])) + .arg(QString::fromStdString(name)) .arg(port_id) .arg(fl ? virt_fl->info().id : virt_fr->info().id) @@ -112,11 +120,16 @@ void start(QString _target) { [&](const pipewire::global &global) { if (global.type == pipewire::node::type) { auto node = reg.bind(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; qDebug(virtmicLog) << QString("Added: %1") - .arg(QString::fromStdString( - node.info().props["application.name"])) + .arg(QString::fromStdString(name)) .toUtf8() .data(); @@ -152,9 +165,13 @@ void start(QString _target) { [&](const std::uint32_t id) { if (nodes.count(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") - .arg(QString::fromStdString( - info.props["application.name"].data())) + .arg(QString::fromStdString(name)) .toUtf8() .data(); nodes.erase(id);