I recently switched back to VLC from MPD/MPC because VLC seems to play more formats and is easier to use/set-up. However I did want to keep my global keybindings, considering I couldn’t find an option in VLC to enable them and knowing that it has a D-Bus interface I decided to figure out how it works.

After some research I found out that VLC adheres to the Media Player Remote Interfacing Specification” (or MPRIS for short) for its D-BUS commands, which can be found here. To use it you can use the command line utility to send D-Bus messages dbus-send for example:

dbus-send --print-reply --session --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop

Which returns.

method return sender=:1.50 -> dest=:1.143 reply_serial=2

And stops the audio output.

The spec lists all the available commands however as I’ll only be using the org.mpris.MediaPlayer2.Player.* commands I made a simple wrapper script:

#!/bin/sh

# Simple proxy script to interface with VLC over DBUS
# Available commands can be found at http://specifications.freedesktop.org/mpris-spec/latest/Player_Node.html

dbus-send --print-reply --session --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.$1

Now I can simply call vlc-proxy <command> to control VLC.

References: