Skip to content

Commit b11a298

Browse files
committed
fix(discord): get work dir from env
Signed-off-by: so5iso4ka <[email protected]>
1 parent 26f0076 commit b11a298

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

launcher/discord/DiscordSocket.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <QDir>
2121
#include <QJsonDocument>
2222
#include <QJsonObject>
23+
#include <QProcessEnvironment>
2324

2425
#include "BuildConfig.h"
2526

@@ -139,6 +140,8 @@ void DiscordSocket::enqueue(const QByteArray& data, Opcode opcode)
139140

140141
void UnixDiscordSocket::connectSocket()
141142
{
143+
const QString runtimeDir = QProcessEnvironment::systemEnvironment().value("XDG_RUNTIME_DIR");
144+
m_path = runtimeDir != "" ? runtimeDir : QDir::tempPath();
142145
emit tryNext();
143146
}
144147

@@ -156,7 +159,7 @@ void UnixDiscordSocket::errorOccurred(QLocalSocket::LocalSocketError socketError
156159
void UnixDiscordSocket::tryNext()
157160
{
158161
if (m_socketIndex < 10) {
159-
const QString path = QDir::tempPath() + "/discord-ipc-" + QString::number(m_socketIndex);
162+
const QString path = m_path + "/discord-ipc-" + QString::number(m_socketIndex);
160163
m_socket.setServerName(path);
161164
m_socket.connectToServer();
162165
} else {

launcher/discord/DiscordSocket.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class UnixDiscordSocket : public DiscordSocket {
8383

8484
private:
8585
int m_socketIndex{};
86+
QString m_path;
8687
};
8788

8889
class WinDiscordSocket : public DiscordSocket {

0 commit comments

Comments
 (0)