Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b6e8fc473 | ||
|
|
8f0a810539 | ||
|
|
a6eb82948f | ||
|
|
24727f398a | ||
|
|
c43e9953a5 | ||
|
|
08cb713e8c | ||
|
|
27faed4a3a | ||
|
|
10fff86ca4 |
@@ -62,6 +62,9 @@ You have multiple options:
|
|||||||
With apt:
|
With apt:
|
||||||
`apt install -y build-essential cmake qtbase5-dev qtwebengine5-dev libkf5notifications-dev libkf5xmlgui-dev libkf5globalaccel-dev pkg-config libpipewire-0.3-dev git`
|
`apt install -y build-essential cmake qtbase5-dev qtwebengine5-dev libkf5notifications-dev libkf5xmlgui-dev libkf5globalaccel-dev pkg-config libpipewire-0.3-dev git`
|
||||||
|
|
||||||
|
With dnf:
|
||||||
|
`dnf install @development-tools cmake qt5-qtbase-devel qt5-qtwebengine-devel kf5-knotifications-devel kf5-kxmlgui-devel kf5-kglobalaccel-devel pkgconfig pipewire-devel git`
|
||||||
|
|
||||||
### Building
|
### Building
|
||||||
|
|
||||||
First, clone the repository:
|
First, clone the repository:
|
||||||
|
|||||||
5636
assets/arrpc.js
5636
assets/arrpc.js
File diff suppressed because one or more lines are too long
@@ -1,65 +1 @@
|
|||||||
setTimeout(e => {
|
setTimeout((i=>{let t,a,s,e={};new WebSocket("ws://127.0.0.1:1337").onmessage=async i=>{if(msg=JSON.parse(i.data),console.log(msg),!t){const i=window.webpackChunkdiscord_app.push([[Symbol()],{},i=>i]),e=i.c;window.webpackChunkdiscord_app.pop();for(const i in e){let a=e[i].exports;if(a=a&&(a.Z??a.ZP),a&&a.register&&a.wait){t=a;break}}const n=i.m;for(const t in n)if(n[t].toString().includes("getAssetImage: size must === [number, number] for Twitch")){const s=i(t),e=Object.values(s).find((i=>"function"==typeof i&&i.toString().includes("apply(")));a=async(i,t)=>(await e(i,[t,void 0]))[0];break}for(const t in n)if(n[t].toString().includes("e.application={")){const a=i(t),e=Object.values(a).find((i=>"function"==typeof i&&i.toString().includes("e.application={")));s=async i=>{let t={};return await e(t,i),t.application};break}}if(msg.activity?.assets?.large_image&&(msg.activity.assets.large_image=await a(msg.activity.application_id,msg.activity.assets.large_image)),msg.activity?.assets?.small_image&&(msg.activity.assets.small_image=await a(msg.activity.application_id,msg.activity.assets.small_image)),msg.activity){const i=msg.activity.application_id;e[i]||(e[i]=await s(i));const t=e[i];msg.activity.name||(msg.activity.name=t.name)}t.dispatch({type:"LOCAL_ACTIVITY_UPDATE",...msg})}}),1e4);
|
||||||
let Dispatcher, lookupAsset, lookupApp, apps = {};
|
|
||||||
|
|
||||||
const ws = new WebSocket('ws://127.0.0.1:1337'); // connect to arRPC bridge websocket
|
|
||||||
ws.onmessage = async x => {
|
|
||||||
msg = JSON.parse(x.data);
|
|
||||||
console.log(msg);
|
|
||||||
|
|
||||||
if (!Dispatcher) {
|
|
||||||
const wpRequire = window.webpackChunkdiscord_app.push([[Symbol()], {}, x => x]);
|
|
||||||
const cache = wpRequire.c;
|
|
||||||
window.webpackChunkdiscord_app.pop();
|
|
||||||
|
|
||||||
for (const id in cache) {
|
|
||||||
let mod = cache[id].exports;
|
|
||||||
mod = mod && (mod.Z ?? mod.ZP);
|
|
||||||
|
|
||||||
if (mod && mod.register && mod.wait) {
|
|
||||||
Dispatcher = mod;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const factories = wpRequire.m;
|
|
||||||
for (const id in factories) {
|
|
||||||
if (factories[id].toString().includes('getAssetImage: size must === [number, number] for Twitch')) {
|
|
||||||
const mod = wpRequire(id);
|
|
||||||
|
|
||||||
const _lookupAsset = Object.values(mod).find(e => typeof e === "function" && e.toString().includes("apply("));
|
|
||||||
lookupAsset = async (appId, name) => (await _lookupAsset(appId, [name, undefined]))[0];
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const id in factories) {
|
|
||||||
if (factories[id].toString().includes(`e.application={`)) {
|
|
||||||
const mod = wpRequire(id);
|
|
||||||
|
|
||||||
const _lookupApp = Object.values(mod).find(e => typeof e === "function" && e.toString().includes(`e.application={`));
|
|
||||||
lookupApp = async appId => {
|
|
||||||
let socket = {};
|
|
||||||
await _lookupApp(socket, appId);
|
|
||||||
return socket.application;
|
|
||||||
};
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg.activity?.assets?.large_image) msg.activity.assets.large_image = await lookupAsset(msg.activity.application_id, msg.activity.assets.large_image);
|
|
||||||
if (msg.activity?.assets?.small_image) msg.activity.assets.small_image = await lookupAsset(msg.activity.application_id, msg.activity.assets.small_image);
|
|
||||||
|
|
||||||
if (msg.activity) {
|
|
||||||
const appId = msg.activity.application_id;
|
|
||||||
if (!apps[appId]) apps[appId] = await lookupApp(appId);
|
|
||||||
|
|
||||||
const app = apps[appId];
|
|
||||||
if (!msg.activity.name) msg.activity.name = app.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dispatcher.dispatch({ type: "LOCAL_ACTIVITY_UPDATE", ...msg }); // set RPC status
|
|
||||||
};
|
|
||||||
}, 10000)
|
|
||||||
@@ -30,7 +30,7 @@ echo_status "Patching arRPC"
|
|||||||
sed -i 's/"type": "module",//' package.json
|
sed -i 's/"type": "module",//' package.json
|
||||||
|
|
||||||
echo_status "Building arRPC"
|
echo_status "Building arRPC"
|
||||||
pnpm exec ncc build src/index.js
|
pnpm exec ncc build -m src/index.js
|
||||||
|
|
||||||
echo_status "Copying built file"
|
echo_status "Copying built file"
|
||||||
cp -v ./dist/index.js ../../assets/arrpc.js
|
cp -v ./dist/index.js ../../assets/arrpc.js
|
||||||
|
|||||||
@@ -282,6 +282,7 @@ void DiscordPage::javaScriptConsoleMessage(
|
|||||||
ansi += "\033[" + cssAnsiColorMap[color] + "m";
|
ansi += "\033[" + cssAnsiColorMap[color] + "m";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (endOfStyles < lines.length())
|
||||||
qDebug(discordLog) << (ansi + lines[0].trimmed() + "\033[0m " +
|
qDebug(discordLog) << (ansi + lines[0].trimmed() + "\033[0m " +
|
||||||
lines[endOfStyles].trimmed())
|
lines[endOfStyles].trimmed())
|
||||||
.toUtf8()
|
.toUtf8()
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ MainWindow::MainWindow(bool useNotifySend, QWidget *parent)
|
|||||||
m_centralWidget = new CentralWidget(this);
|
m_centralWidget = new CentralWidget(this);
|
||||||
setCentralWidget(m_centralWidget);
|
setCentralWidget(m_centralWidget);
|
||||||
setupTrayIcon();
|
setupTrayIcon();
|
||||||
|
setMinimumSize(800, 300);
|
||||||
if (m_settings->contains("geometry")) {
|
if (m_settings->contains("geometry")) {
|
||||||
restoreGeometry(m_settings->value("geometry").toByteArray());
|
restoreGeometry(m_settings->value("geometry").toByteArray());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ void UserScript::setupHelpMenu() {
|
|||||||
QString(), "https://github.com/Curve");
|
QString(), "https://github.com/Curve");
|
||||||
aboutData.addComponent("Rohrkabel", "A C++ RAII Pipewire-API Wrapper", "1.3",
|
aboutData.addComponent("Rohrkabel", "A C++ RAII Pipewire-API Wrapper", "1.3",
|
||||||
"https://github.com/Soundux/rohrkabel");
|
"https://github.com/Soundux/rohrkabel");
|
||||||
|
aboutData.addComponent("arRPC",
|
||||||
|
"An open implementation of Discord's local RPC "
|
||||||
|
"servers<br>Copyright (c) 2022 OpenAsar",
|
||||||
|
nullptr, "https://github.com/OpenAsar/arrpc");
|
||||||
m_helpMenu = new KHelpMenu(MainWindow::instance(), aboutData);
|
m_helpMenu = new KHelpMenu(MainWindow::instance(), aboutData);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,25 @@ namespace Virtmic {
|
|||||||
|
|
||||||
const QStringList EXCLUDE_TARGETS{"Chromium input", "discord-screenaudio"};
|
const QStringList EXCLUDE_TARGETS{"Chromium input", "discord-screenaudio"};
|
||||||
|
|
||||||
|
const std::string nullstr = "";
|
||||||
|
const std::string &getTarget(const pipewire::spa::dict &props) {
|
||||||
|
if (props.count("media.class") &&
|
||||||
|
props.at("media.class") == "Stream/Output/Audio") {
|
||||||
|
if (props.count("application.name") && props.at("application.name") != "")
|
||||||
|
return props.at("application.name");
|
||||||
|
else if (props.count("application.process.binary") &&
|
||||||
|
props.at("application.process.binary") != "")
|
||||||
|
return props.at("application.process.binary");
|
||||||
|
else
|
||||||
|
return props.at("node.name");
|
||||||
|
} else
|
||||||
|
return nullstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString qGetTarget(const pipewire::spa::dict &props) {
|
||||||
|
return QString::fromStdString(getTarget(props));
|
||||||
|
}
|
||||||
|
|
||||||
QVector<QString> getTargets() {
|
QVector<QString> getTargets() {
|
||||||
auto main_loop = pipewire::main_loop();
|
auto main_loop = pipewire::main_loop();
|
||||||
auto context = pipewire::context(main_loop);
|
auto context = pipewire::context(main_loop);
|
||||||
@@ -22,14 +41,7 @@ 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();
|
||||||
QString name;
|
QString name = qGetTarget(info.props);
|
||||||
if (info.props.count("application.name") &&
|
|
||||||
info.props["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)) {
|
||||||
targets.append(name);
|
targets.append(name);
|
||||||
@@ -73,13 +85,7 @@ void start(QString _target) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto &parent = nodes.at(parent_id);
|
auto &parent = nodes.at(parent_id);
|
||||||
std::string name;
|
std::string name = getTarget(parent.props);
|
||||||
if (parent.props.count("application.name") &&
|
|
||||||
parent.props["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]" &&
|
||||||
!EXCLUDE_TARGETS.contains(QString::fromStdString(name)))) {
|
!EXCLUDE_TARGETS.contains(QString::fromStdString(name)))) {
|
||||||
@@ -99,7 +105,7 @@ void start(QString _target) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string target = _target.toLatin1().toStdString();
|
std::string target = _target.toUtf8().toStdString();
|
||||||
|
|
||||||
auto virtual_mic = core.create("adapter",
|
auto virtual_mic = core.create("adapter",
|
||||||
{{"node.name", "discord-screenaudio-virtmic"},
|
{{"node.name", "discord-screenaudio-virtmic"},
|
||||||
@@ -123,13 +129,8 @@ void start(QString _target) {
|
|||||||
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();
|
||||||
std::string name;
|
std::string name = getTarget(info.props);
|
||||||
if (info.props.count("application.name") &&
|
if (name == nullstr)
|
||||||
info.props["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(name))
|
.arg(QString::fromStdString(name))
|
||||||
@@ -168,12 +169,9 @@ 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;
|
std::string name = getTarget(info.props);
|
||||||
if (info.props.count("application.name") &&
|
if (name == nullstr)
|
||||||
info.props["application.name"] != "")
|
return;
|
||||||
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(name))
|
.arg(QString::fromStdString(name))
|
||||||
.toUtf8()
|
.toUtf8()
|
||||||
|
|||||||
Reference in New Issue
Block a user