Jorisvandijk.com

Future full-stack developer

Control MPV playback with playerctl

This is a very short one. I love to use MPRIS (Media Player Remote Interfacing Specification), which is a standard DBUS interface to manage (among other things) audio playback on your system. The Spotify Electron app for one uses this, which means you can use commands, which you should link to keybindings, to go to the next or previous track, or to play and pause playback.

So as an SXHKD keybinding that'd be something like:

super + {Down, Left, Right}
playerctl {play-pause, previous, next}

Or for an i3 binding, maybe:

bindsym  $mod+Down exec --no-startup-id playerctl play-pause
bindsym $mod+Left exec --no-startup-id playerctl previous
bindsym $mod+Right exec --no-startup-id playerctl next

This means that, no matter the desktop I am on, I'll be able to stop playback with a keybinding, or at least, for applications that support this.

My video player of choice is MPV, but one downside of it is that it does not support MPRIS. Luckily Ho-Yon Mak decided this was a massive oversight as well and made a plugin named MPV-MPRIS. It will, like magic, enable the use of my beloved keybindings for MPV. It is availible in most Linux distributions package managers. For Arch, this is how to install it:

sudo pacman -S mpv-mpris

And it just works out of the box. No need for doing any setup or changing settings. Install and play!