ronny/apple-music-discord
macOS app that updates the user's rich presence in Discord with currently playing Apple Music track
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.
Optional:
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.
⚠️ The Discord Social SDK is required - the build will fail if not found.
🔐 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:
DISCORD_APP_ID
environment variable:export DISCORD_APP_ID=your_application_id_here
⚠️ Required: The DISCORD_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=ReleaseFast
Music.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-integration
main.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 uses lib/debug/
, Release modes use lib/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"
"DISCORD_APP_ID environment variable must be set at compile time" (Build failure)
DISCORD_APP_ID
environment variable before buildingDISCORD_APP_ID=1234567890123456789 zig build
"Discord Social SDK not found" (Build failure)
$HOME/src/discord_social_sdk
-Ddiscord-social-sdk=/path/to/social-sdk
Build errors with Music.h
zig build Music.h
to regenerate the headerNo track changes detected
--interval 200
macOS Security popup for Discord Social SDK library
libdiscord_partner_sdk.dylib
and click "Allow Anyway"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