Skip to content

Add native MPRIS D-Bus support for mpris/playerctl and waybar-mpris module#648

Open
rbrgmn wants to merge 1 commit intoncmpcpp:masterfrom
rbrgmn:feature/mpris-dbus
Open

Add native MPRIS D-Bus support for mpris/playerctl and waybar-mpris module#648
rbrgmn wants to merge 1 commit intoncmpcpp:masterfrom
rbrgmn:feature/mpris-dbus

Conversation

@rbrgmn
Copy link

@rbrgmn rbrgmn commented Feb 23, 2026

This PR adds native MPRIS2 support to ncmpcpp, so it can be controlled directly via D-Bus clients such as playerctl and consumed by status bars like Waybar without external bridges.

What’s included:

  • New optional MPRIS D-Bus module:
    • src/mpris_dbus.cpp
    • src/mpris_dbus.h
  • Build integration:
    • configure.ac: adds --enable-dbus-mpris and dbus-1 detection
    • src/Makefile.am: adds new source/header
  • Runtime integration in main loop:
    • initialize/shutdown MPRIS
    • process D-Bus events in the main loop
    • register D-Bus fd callback on footer window

Implemented interfaces:

  • org.mpris.MediaPlayer2
  • org.mpris.MediaPlayer2.Player
  • org.freedesktop.DBus.Properties
  • org.freedesktop.DBus.Introspectable

Implemented properties/methods/signals:

  • Properties: Get, GetAll, Set
  • Player methods: Play, Pause, PlayPause, Stop, Next, Previous, Seek, SetPosition, OpenUri
  • Signals: PropertiesChanged, Seeked
  • Player properties include:
    • PlaybackStatus, Metadata, Position
    • LoopStatus, Shuffle, Volume, Rate, MinimumRate, MaximumRate
    • CanGoNext, CanGoPrevious, CanPlay, CanPause, CanSeek, CanControl
  • MediaPlayer2 properties include:
    • Identity, DesktopEntry
    • SupportedUriSchemes, SupportedMimeTypes
    • CanQuit, CanRaise, CanSetFullscreen, Fullscreen, HasTrackList

Behavior notes:

  • Rate is exposed for MPRIS compatibility; only 1.0 is accepted.
  • HasTrackList is false (TrackList interface is not implemented).
  • Metadata includes standard fields like mpris:trackid, mpris:length, xesam:title, xesam:artist, xesam:album, xesam:url.

Why?
This enables first-class interoperability with the Linux media ecosystem (playerctl, Waybar, other MPRIS consumers) directly from ncmpcpp, without requiring separate MPD MPRIS bridge processes.

Build instructions:

  • Regenerate autotools files:
    autoreconf -fi
  • Configure with native MPRIS enabled:
    ./configure --enable-dbus-mpris
  • Build:
    make -j"$(nproc)"
  • Optional install:
    sudo make install
  • Run:
    ./src/ncmpcpp

Dependencies

  • dbus-1 (required when --enable-dbus-mpris is used)
  • regular ncmpcpp deps (libmpdclient, ncursesw, boost, etc.)

Quick runtime check
playerctl -l
playerctl -p ncmpcpp status

Manual testing:

  • playerctl -l shows ncmpcpp
  • playerctl -p ncmpcpp status
  • playerctl -p ncmpcpp play-pause
  • playerctl -p ncmpcpp next
  • playerctl -p ncmpcpp previous
  • playerctl -p ncmpcpp metadata
  • Waybar mpris module displays and updates state/track info without UnknownProperty errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant