Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Discord RPC and firejail

A topic by Blubberquark Software created Aug 10, 2018 Views: 1,267 Replies: 2
Viewing posts 1 to 3

I have recently started to integrate the itch.io API and the Discord RPC API into a new game of mine. The Discord RPC API uses Unix domain sockets on Mac and Linux, and named pipes on Windows.

I have tried to get it to work inside the itch app, and I can open the socket, but it fails in a rather tricky way: Firejail hides all other processes. Inside firejail it looks like I have PID 3, and I can't get my "external" PID. When I try to talk to Discord, Discord can't find my game process running, but it looks like everything works fine and my game runs as PID 3.

I probably won't even be able to open the named pipe on Win32 because the game is not running as the user who crated the pipe, but I haven't checked that yet.

I like that I can mark my game as sandbox-compatible in the manifest, but if I don't think I will opt my games into them yet, if it works inconsistently across platforms.

If I could get an environment variable like ITCHIO_SANDBOX=firejail or ITCHIO_SANDBOX=win_user, that would help a bunch. I could just disable the Discord RPC and save myself headache and bug reports, and if the variable isn't set, I could go on as usual.

Even better for Discord RPC specifically would be a way to get the PID (like in ITCHIO_GAME_PID=12345) from the butler process that started the game, but that's such a Discord-specific thing I'm not sure it's worth the effort, and if you decide to put effort into Discord things, you (probably Amos) might as well implement the presence API yourself, because know the game's name (but not the internal game state).

Are there any other devs on itch.io who use SDKs and APIs like that?

Hey there,

Does that work for you? https://github.com/itchio/butler/commit/a46969012a3bd3f0ef48ea7d54f9f6750ec1387e

You're right, I doubt passing ITCHIO_GAME_PID would be general enough to be justifiable, and implementing the Presence API ourselves would be a good idea. Feel free to open an issue at https://github.com/itchio/itch/issues

Thanks. That helps a ton already, provided you won't switch sandbox mechanisms anytime soon. For now, I'll hard-code my games not to try things that won't work in the sandbox.

If you implement Discord RPC in itch, you should probably add a parameter to the manifest that configures if a game handles its own rich presence.

I wanted to implement Discord RPC for matchmaking mostly, so you can click "join game", but that's something I need to bake into my own game logic. Instead of queueing and waiting in the game client, you can idle in Discord and invite people on your friend list. Queueing times for a small indie games might be hours otherwise.

The galaxy brain solution would be to run Discord in the same sandbox... As I understand it, itch sandboxing on Windows uses a separate user account that is basically shared between all itch games. Sandboxing Discord might be a good idea anyway, but then automatic game detection won't work, because Discord needs to look at other processes.