Support for Flatpak version of Discord

This commit is contained in:
Phin 2024-01-04 11:32:39 +05:30
parent b94ee58353
commit 2bb484b61a
3 changed files with 16 additions and 2 deletions

8
.github/release-notes/v2.4.3.md vendored Normal file
View file

@ -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)

View file

@ -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"

View file

@ -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