A macOS application that listens to Apple Music.app and updates the user's rich presence in Discord.app running locally.
The app works with macOS Sequoia. By "works" I mean it's good enough for me. The rich presence in Discord has the song title and artist name, song duration and progress, but there's no album art, and there's no link to the song on Apple Music, the link goes to the generic Apple Music search page with the artist name and song title. Apple sure made it really difficult to do this 😞
If you want a copy of the app, then you'd need to build it yourself, I'm not providing precompiled binaries.
The app is currently command line only, there's no GUI. I might add a GUI later if I can be bothered and have time. There's no startup script, you need to run it manually (maybe in a tmux or zellij session). There's no process supervision, you need to restart it manually when it crashes.
Bug reports and pull requests welcome, but unless it's a serious issue and easily reproducible, it will probably take me a while to fix.
- macOS (tested on macOS 15.6+)
- Zig compiler (tested with 0.15.1) https://ziglang.org
- Discord Social SDK see below
Optional:
- Xcode (full version, not just Command Line Tools, only when you need to regenerate
Music.h)
Download the Discord Social SDK 1.5 from: https://discord.com/developers/applications/YOUR_APP_ID/social-sdk/downloads (you need to replace YOUR_APP_ID with your actual Discord application ID, see below to set one up)
Extract to $HOME/src/discord_social_sdk or specify a custom path during build.
🔐 macOS Security Note: On first run, macOS will show a security popup for
libdiscord_partner_sdk.dylib. You must manually allow it in System Settings → Privacy & Security
→ Security → libdiscord_partner_sdk.dylib "Allow Anyway".
Before building, you need to create a Discord application and get your Application ID:
- Go to https://discord.com/developers/applications
- Create a new application
- Copy the Application ID from the General Information page
- Set the
DISCORD_APP_IDenvironment variable:
export DISCORD_APP_ID=your_application_id_hereDISCORD_APP_ID environment variable must be set at build time. The build will
fail if not provided.
# Set your Discord App ID (if you don't want to type it every time)
export DISCORD_APP_ID=1234567890123456789
# Debug build with default location of Discord Social SDK of $HOME/src/discord_social_sdk
# and lib/debug for the dynamic lib.
DISCORD_APP_ID=... zig build
# Release build with default location of Discord Social SDK of $HOME/src/discord_social_sdk
# and lib/release for the dynamic lib.
DISCORD_APP_ID=... zig build -Doptimize=ReleaseFast
# Build with custom Discord Social SDK location and lib/debug
DISCORD_APP_ID=... zig build -Ddiscord-social-sdk=/path/to/discord_social_sdk
# Build with custom Discord Social SDK location and lib/release
DISCORD_APP_ID=... zig build -Ddiscord-social-sdk=/path/to/discord_social_sdk -Doptimize=ReleaseFastMusic.h is generated based on the currently present Apple Music.app, so it's probably
version specific. If it's out of sync, you can regenerate it by running zig build Music.h.
# Generate Music.h header (requires full Xcode installation)
zig build Music.h# Run with default settings (must build first with DISCORD_APP_ID)
DISCORD_APP_ID=... zig build run
# Or run the built binary directly
./zig-out/bin/music-discord-presence
# Run with custom polling interval
./zig-out/bin/music-discord-presence --interval 1000
# Show help
./zig-out/bin/music-discord-presence --help# Run all tests (DISCORD_APP_ID still required for build)
DISCORD_APP_ID=1234567890123456789 zig build test-all
# Run specific test suites
DISCORD_APP_ID=1234567890123456789 zig build test-config
DISCORD_APP_ID=1234567890123456789 zig build test-music
DISCORD_APP_ID=1234567890123456789 zig build test-integrationmain.zig- Main application with polling-based track detectionMusicScriptingBridge.{m,h}- Objective-C bridge to Apple Music.appMusic.h- Generated header from Apple Music.apptests/- Comprehensive test suite
--interval, -i <ms>- Polling interval in milliseconds (default: 500ms, minimum: 100ms)--help, -h- Show help message
-Ddiscord-social-sdk=<path>- Specify Discord Social SDK location-Dtarget=<target>- Cross-compilation target-Doptimize=<mode>- Optimization mode (Debug useslib/debug/, Release modes uselib/release/)Debug(default) - Uses Discord Social SDK debug libraryReleaseFast- Uses Discord Social SDK release library (recommended for distribution)ReleaseSafe- Uses Discord Social SDK release library with safety checksReleaseSmall- Uses Discord Social SDK release library optimized for size
"Apple Music is not running"
- Ensure Apple Music.app is launched and playing music
"DISCORD_APP_ID environment variable must be set at compile time" (Build failure)
- Set the
DISCORD_APP_IDenvironment variable before building - Get your Application ID from https://discord.com/developers/applications
- Example:
DISCORD_APP_ID=1234567890123456789 zig build - Build will not proceed without DISCORD_APP_ID
"Discord Social SDK not found" (Build failure)
- Download Discord Social SDK from Discord Developer Portal
- Extract to
$HOME/src/discord_social_sdk - Or specify custom path with
-Ddiscord-social-sdk=/path/to/social-sdk - Build will not proceed without Discord Social SDK
Build errors with Music.h
- Run
zig build Music.hto regenerate the header - Requires full Xcode installation (not just Command Line Tools)
No track changes detected
- Default polling interval is 500ms
- Try lower interval:
--interval 200 - Ensure Apple Music.app is actively playing different tracks
macOS Security popup for Discord Social SDK library
- macOS will block unsigned libraries on first run
- Go to System Settings → Privacy & Security → Security
- Find
libdiscord_partner_sdk.dyliband click "Allow Anyway" - Restart the application after allowing the library
This application uses polling-based track detection via Apple Music.app's ScriptingBridge API. The notification-based approach was found to be non-functional on modern macOS versions and has been deprecated.
Data Flow:
main.zig → MusicScriptingBridge → Apple Music ScriptingBridge → Discord Social SDK