atom-discord icon indicating copy to clipboard operation
atom-discord copied to clipboard

Add a flatpak IPC workaround

Open Douile opened this issue 4 years ago • 0 comments

When using the flatpak version of discord com.discordapp.Discord (from flathub) the IPC channel is moved to /run/users/$UID/app/com.discordapp.Discord/. I noticed you have a workaround for snaps which changes the prefix, It would be nice if you could add a similar workaround for flatpaks. Using your workaround I was able to get discord-rpc to work with the following.

const rpc = new Client({ transport: 'ipc' });

let previousPath = process.env.XDG_RUNTIME_DIR;
const { env: { XDG_RUNTIME_DIR, TMPDIR, TMP, TEMP } } = process;
let prefix = XDG_RUNTIME_DIR || TMPDIR || TMP || TEMP || '/tmp';

prefix = prefix.replace(/\/$/, '') + '/app/com.discordapp.Discord';

process.env.XDG_RUNTIME_DIR = prefix;

console.log(`Redirected XDG_RUNTIME_DIR into ${prefix}`);

rpc.login({ clientId });

I would PR but I don't know how to add the buttons in atom. Thanks for the awesome package and I hope this can get added.

Douile avatar Nov 30 '20 14:11 Douile