Skip to content

Repository files navigation

MATLAB Discord Rich Presence Integration

Author: Devon Yanitski and Gemini CLI 0.1.13 View Discord Rich Presence on File Exchange

This toolbox integrates Discord Rich Presence with MATLAB, allowing you to display the .m file you are currently editing in your Discord status. It automatically updates as you switch between files, similar to the VS Code "vscord" extension.

Demo Image

Features

  • Automatic Detection: Shows the currently active file in the MATLAB editor.
  • Real-Time Updates: Status updates within seconds of switching files.
  • Silent & Efficient: Runs in the background with minimal performance impact.
  • Easy Setup: A one-time setup command is all that's needed.
  • Cross-Platform: Works on Windows, macOS, and Linux.

Installation

  1. Install the Toolbox:

    • Download the .mltbx file from the latest release.
    • Double-click the .mltbx file or drag it into the MATLAB command window.
    • Follow the on-screen instructions to complete the installation.
  2. Run the Setup Command:

    • After installation, run the following command in the MATLAB console:

      discordrpc.setup()
  3. Follow On-Screen Prompts:

    • The setup script will check for Python and the required pypresence library.
    • If pypresence is not found, it will prompt you to install it automatically.
    • It will also configure MATLAB to start the integration automatically on launch and stop it when MATLAB closes.
  4. Restart MATLAB:

    • For the changes to take effect, restart MATLAB.
  5. Ensure Discord is Running:

    • The integration requires the Discord desktop application to be running in the background.

Usage

Once installed and set up, the integration runs automatically. There are no further steps required. Your Discord status will show the file you are editing whenever MATLAB is open.

To manually control the integration, you can use the following commands:

  • Start the integration:
    discordrpc.start()
  • Stop the integration:
    discordrpc.stop()

How It Works

The toolbox uses a background MATLAB timer to periodically check the active file in the editor. When a file change is detected, it calls a lightweight Python script (update_presence.py) that communicates with the local Discord client via its Rich Presence API.

This approach is necessary because MATLAB cannot directly interface with Discord's IPC socket.

Troubleshooting

  • "Python not found": Ensure Python is installed and its location is included in your system's PATH environment variable.

    On Windows, install Python from python.org rather than the Microsoft Store. The Store version places a stub named python.exe on your PATH that opens the Store instead of running Python; the toolbox skips that stub, but it can leave you with no usable interpreter.

  • "pypresence not installed": If the automatic installation fails, open a terminal or command prompt and run: pip install pypresence.

  • "The background helper did not start": Python launched but the helper script exited immediately, almost always because pypresence is missing from the interpreter the toolbox found. The warning names that interpreter; install pypresence into it specifically, then run discordrpc.setup() again.

  • Status not updating: Make sure Discord is running and that you have enabled "Display current activity as a status message" in Discord's settings (User Settings > Activity Privacy).

    You do not need to start Discord before MATLAB. The helper retries the connection every 15 seconds, so your status appears shortly after Discord comes up.

  • Status stuck after MATLAB closed: The helper watches the MATLAB process that started it and exits within a few seconds of MATLAB going away, including after a crash or a force quit. If a status somehow persists, discordrpc.stop() in a new MATLAB session clears it.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages