Set custom Discord Rich Presence via Remote Procedure Calls.
Note
When the activity type is 5 (Competing in), the activity name is placed in the "Competing in {name}" string, the details field replaces the name in the bolded title, and the state field is just below. The third line is, for whatever reason, filled in with the large image hover text. If the activity type is changed to 0 (Playing), the bold title would be "Yapping", and the two lines below would contian the details and state fields, respectively, and the large image hover text would only appear when hovering over the large image.
Please create an issue for any unintended behavior. PRs and other contributions are welcome.
Clone the repo, install dependencies, copy and edit the config file, and run the app. Simple.
git clone https://github.com/ackledotdev/custom-rpc.git # gh repo clone ackledotdev/custom-rpc
cd custom-rpc
npm i
cp example.jsonc config.jsonc # Copy the example config file
vi config.jsonc # Edit as desired
npm startCaution
If your Discord online status (Online, Do Not Disturb, Invisible) is set to Invisible, your current Activity (including Rich Presence!) will be hidden.
Important
Running the app with the default config file will produce something similar to the sample image, assuming that is up-to-date. You must edit the config file and specify your own Client ID from the Discord Developer Portal to add your own images. See "Advanced setup". If you are not using images, this will not be necessary, but you must comment out the image section to hide the images.
- Create an application on the Discord Developer Portal and copy the Client/Application ID. No other fields need to be changed. They will not affect the Rich Presence.
- Enter your Client ID in the config file.
- Upload images to the Rich Presence art assets tab of your application settings. Ensure the images are keyed properly before saving.
- In the config file, update the image keys to match the keys of the uploaded images. Edit hover text as desired.
- Run the app with
npm start.
Add the watch argument to watch the config file for changes and automatically refresh the Rich Presence without restarting the app.
npm start -- watchNote
The -- watch is not a typo; the double dash separates npm args from the args passed to the script.
Important
The refreshTime value in the config file is only read on initial startup; to accept a new value, the app must be restarted.
A sample systemd user unit file is provided.
cp custom-rpc.service ~/.config/systemd/user/ # copy the service file
vi ~/.config/systemd/user/custom-rpc.service # edit the ExecStarta path to point to your installation
systemctl --user enable --now custom-rpc.service # start the service and enable start on login if desired
# or
systemctl --user start custom-rpc.service # start the service nowOptionally, remove the watch argument from the startup script to disable refreshing config changes without restarting the service.
npm start -- watchHowever, this will create a file watcher that scans continuously for updates. The service can always be refreshed manually with systemctl --user restart custom-rpc.service after editing the config file. Note that the That is no longer the case. refreshTime value is only read on initial startup; to accept a new value, the service must be restarted.refreshTime is handled on config reload.
Configs can be switched on the fly by starting the process with the watch argument in either the CLI or systemd startup script. Instead of editing the config file, create multiple config files and copy the desired config to config.jsonc.
cp example.jsonc config.jsonc # switch to example.jsonc
cp /home/user/another_config.jsonc config.jsonc # switch to another_config.jsonc
echo '{}' > config.jsonc # clear Rich Presence
echo '' > config.jsonc # another way to clear Rich PresenceThe app will detect the change and reload the new config automatically. An empty config file or one containing an empty object ({}) will disconnect from the Rich Presence server without terminating the app.
- File watch mode must be enabled.
- It is imperative that the file exists the entire time the app is running; deleting the file will cause the program to terminate with an error. An empty config file will allow the program to keep watching but clear the Rich Presence.
- The config loaded at startup must have the correct Client ID for the Discord application; changing the Client ID on the fly is not supported and will be ignored.
I've tried to hotswitch configs by symlinking config.jsonc to different config files, but that hasn't worked consistently. If anyone gets that working, please create a pull request or something.
