HelloWorld017 / atom-discord

Integrate with Discord and show Rich Presence information.
https://atom.io/packages/atom-discord
MIT License
106 stars 29 forks source link

Add a flatpak IPC workaround #114

Open Douile opened 3 years ago

Douile commented 3 years ago

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.