Discord
Discord is a proprietary, cross-platform, all-in-one voice and text chat application.
Install Discord from the repositories:
pacman -S discord
Or the official Flatpak app:
flatpak install com.discordapp.Discord
Rich Presence with Flatpak
Discord provides a Unix socket file that games and applications use in order to show what game or media is currently being played.
The Flatpak version creates this socket in a different location than the repo package version. In order for games and apps to still be able to communicate with the Discord app, a symbolic link needs to be created in the usual place, pointing to the location of the socket file of the Flatpak version.
The most straightforward way is to create a symbolic link with a single command:
ln -sf $XDG_RUNTIME_DIR/{app/com.discordapp.Discord,}/discord-ipc-0
However, since $XDG_RUNTIME_DIR is a tmpfs in RAM, its contents will be discarded if the system is shut down or rebooted. To fix this, systemd-tmpfiles can be used to automatically re-create the link every time you log into your desktop session.
Create the directory user-tmpfiles.d in your user's .config directory:
mkdir -p ~/.config/user-tmpfiles.d
In the newly created directory, create a new config file:
nano ~/.config/user-tmpfiles.d/discord-ipc.conf
systemd-tmpfiles uses the information in the config file to create temporary files as long as the user is logged in and remove them once the user logs out.
The fields in this file are space separated. The fields are as follows:
| Field | Description |
|---|---|
| Type | The type of file to create. L = symbolic link, d = directory, f = regular file. |
| Path | Path where to create the object. %t = signifier for user-specific temporary directory (/run/user/[ID]). |
| Mode | File permissions in octal notation. - means keep the default. |
| Owner | User who will own the file. - means keep the default. |
| Group | Group who will own the file. - means keep the default. |
| Time | Expiration time of the file, e.g. 2h deletes the files after 2 hours. - means no expiration time. |
| Options | Parameters specific to the type used in the type field. When L, it's the target the link will point to. |
In order for the link to point to the Discord socket of the Flatpak version, the resulting config file should look have this line:
L %t/discord-ipc-0 - - - - app/com.discordapp.Discord/discord-ipc-0
This will create a symbolic link at /run/user/1000/discord-ipc-0 pointing to the actual socket file at /run/user/1000/app/com.discordapp.Discord/discord-ipc-0 where the Flatpak version of Discord is listening on incoming connections from other apps and games.
systemd-tmpfiles will not pick up on the new config file automatically, it will however read it upon next log-in. Alternatively, run systemd-tmpfiles --user --create manually to have systemd-tmpfiles create the link for you.