Skip to content

ackledotdev/custom-rpc

Repository files navigation

custom-rpc

Set custom Discord Rich Presence via Remote Procedure Calls.

example screenshot

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.

Usage

Bare minimum

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 start

Caution

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.

Advanced setup

  1. 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.
  2. Enter your Client ID in the config file.
  3. Upload images to the Rich Presence art assets tab of your application settings. Ensure the images are keyed properly before saving.
  4. In the config file, update the image keys to match the keys of the uploaded images. Edit hover text as desired.
  5. Run the app with npm start.

Watching for config changes

Add the watch argument to watch the config file for changes and automatically refresh the Rich Presence without restarting the app.

npm start -- watch

Note

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.

Systemd

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 now

Optionally, remove the watch argument from the startup script to disable refreshing config changes without restarting the service.

npm start -- watch

However, 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 refreshTime value is only read on initial startup; to accept a new value, the service must be restarted. That is no longer the case. refreshTime is handled on config reload.

Config hotswitch

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 Presence

The 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.

Symlinking configs

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors