From 2bb484b61a100f7d7fe85ed5c0893d955e1ce276 Mon Sep 17 00:00:00 2001 From: Phin <59180111+phin05@users.noreply.github.com> Date: Thu, 4 Jan 2024 11:32:39 +0530 Subject: [PATCH] Support for Flatpak version of Discord --- .github/release-notes/v2.4.3.md | 8 ++++++++ config/constants.py | 2 +- core/discord.py | 8 +++++++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 .github/release-notes/v2.4.3.md diff --git a/.github/release-notes/v2.4.3.md b/.github/release-notes/v2.4.3.md new file mode 100644 index 0000000..d41e1f9 --- /dev/null +++ b/.github/release-notes/v2.4.3.md @@ -0,0 +1,8 @@ +### Release Notes + +* Added support for Flatpak version of Discord (#75) + +### Installation Instructions + +* [Regular](https://github.com/phin05/discord-rich-presence-plex/blob/v2.4.3/README.md#installation) +* [Docker](https://github.com/phin05/discord-rich-presence-plex/blob/v2.4.3/README.md#run-with-docker) diff --git a/config/constants.py b/config/constants.py index d2f09c2..b68e0b0 100644 --- a/config/constants.py +++ b/config/constants.py @@ -2,7 +2,7 @@ import os import sys name = "Discord Rich Presence for Plex" -version = "2.4.2" +version = "2.4.3" plexClientID = "discord-rich-presence-plex" discordClientID = "413407336082833418" diff --git a/core/discord.py b/core/discord.py index b716cae..ae9aaa3 100644 --- a/core/discord.py +++ b/core/discord.py @@ -14,7 +14,13 @@ class DiscordIpcService: ipcPipeNumber = ipcPipeNumber or -1 ipcPipeNumbers = range(10) if ipcPipeNumber == -1 else [ipcPipeNumber] ipcPipeBase = ("/run/app" if os.path.isdir("/run/app") else os.environ.get("XDG_RUNTIME_DIR", os.environ.get("TMPDIR", os.environ.get("TMP", os.environ.get("TEMP", "/tmp"))))) if isUnix else r"\\?\pipe" - self.ipcPipes = [os.path.join(ipcPipeBase, f"discord-ipc-{ipcPipeNumber}") for ipcPipeNumber in ipcPipeNumbers] + self.ipcPipes: list[str] = [] + for ipcPipeNumber in ipcPipeNumbers: + pipeFilename = f"discord-ipc-{ipcPipeNumber}" + self.ipcPipes.append(os.path.join(ipcPipeBase, pipeFilename)) + if ipcPipeBase == os.environ.get("XDG_RUNTIME_DIR"): + self.ipcPipes.append(os.path.join(ipcPipeBase, "app", "com.discordapp.Discord", pipeFilename)) + self.ipcPipes.append(os.path.join(ipcPipeBase, ".flatpak", "com.discordapp.Discord", "xdg-run", pipeFilename)) self.loop: Optional[asyncio.AbstractEventLoop] = None self.pipeReader: Optional[asyncio.StreamReader] = None self.pipeWriter: Optional[asyncio.StreamWriter] = None