mpdmacs

A lightweight MPD client.

This manual corresponds to mpdmacs version 1.0.0.

Table of Contents


1 Introduction

The Music Player Daemon (or MPD) is a “flexible, powerful, server-side application for playing music.” It offers an API for interacting with the daemon & building client applications. elmpd is a lightweight, asynchronous Emacs Lisp package for talking to an MPD instance over that protocol.

mpdmacs is an Emacs Minor Mode built on elmpd that turns Emacs into a lightweight MPD client; so lightweight, in fact, that it provides almost no user interface– merely a collection of commands & hooks that are generally available when writing code, reading mail & so forth.

Instructions for obtaining & installing the package may be found in the README. Configuration options are described below and the features offered by the minor mode are described in What the mpdmacs Minor Mode Can Do.


2 Configuring the mpdmacs Minor Mode

Before loading & enabling mpdmacs-mode, the reader will need to configure it with the location of the MPD instance to be controlled. If communications over TCP/IP are desired, set the following two variables:

User Option: mpdmacs-host

The hostname on which MPD is listening.

User Option: mpdmacs-port

The port at which MPD is listening.

If, however, the reader would prefer to communicate with MPD over its Unix socket:

User Option: mpdmacs-socket

The path of the Unix socket on which MPD is listening. If the TCP/IP socket is preferred, it is best to set this to nil: mpdmacs-mode will try the local socket first, if it exists.

mpdmacs supplies several interactive commands (see see below), with keybindings in mpdmacs-mode-keymap; you may want to map a chord you find convenient to that keymap like so:

(defun my-mpdmacs-hook ()
  (global-set-key "\C-c m" 'mpdmacs-mode-keymap))
(add-hook 'mpdmacs-mode-hook 'my-mpdmacs-hook)

Having installed & configured mpdmacs, load it as usual:

(require 'mpdmacs)

At this point, mpdmacs has done nothing: it needs to be explicitly enabled by calling mpdmacs-mode:

Command: mpdmacs-mode &optional ARG

Turn mpdmacs-mode on & off. Interactively, with no prefix argument, toggle the mode. A prefix argument enables the mode if the argument is positive, and disables it otherwise.

When called from Lisp, toggle the mode if the argument is toggle, disable the mode if the argument is a non-positive integer, and enables the mode otherwise (including if the argument is omitted or nil or a positive integer).

Enabling the minor mode will open a connection to your MPD server, begin monitoring its state for changes, and enable the caller to begin issuing commands.


3 What the mpdmacs Minor Mode Can Do

mpdmacs, in contrast to mpdel or mpc, is not a full-fledged application, but rather a global minor mode. As such, it provides no (or, at least, not a dedicated) user interface but rather a suite of commands that are available at all times; while editing code, reading email or RSS, and so on.


3.1 Acting as a Player Controller

The most basic function of the mpdmacs minor mode is to provide a set of command for controlling MPD playback.

Command: mpdmacs-play

Begin playing the current playlist (cf. MPD command play).

Command: mpdmacs-stop

Stop playback (cf. MPD command stop).

Command: mpdmacs-toggle-pause

Pause or resume playback (toggles; cf. MPD command pause).

Command: mpdmacs-replay

Seeks back to time zero in the current track (cf. MPD command seekcur).

Command: mpdmacs-next

Plays the next song in the current playlist (cf. MPD command next).

Command: mpdmacs-previous

Plays the previous song in the current playlist (cf. MPD command previous).

Command: mpdmacs-set-volume ARG

Set the MPD volume to ARG, which must be an integer in the range 0-100 (cf. MPD command setvol).

Command: mpdmacs-inc-volume

Increment the MPD volume; takes a numeric prefix argument (defaults to one).

Command: mpdmacs-dec-volume

Decrement the MPD volume; takes a numeric prefix argument (defaults to one).


3.2 Setting MPD Configuration Options

Command: mpdmacs-toggle-random

Toggle the state of the MPD random option.

Command: mpdmacs-toggle-consume

Toggle the state of the MPD consume option.

Command: mpdmacs-set-crossfade

Set the MPD crossfade option; takes a numeric prefix argument; lacking that read the number of seconds.

Command: mpdmacs-rotate-single

Rotate through the MPD single settings: off, enabled, or oneshot.

Command: mpdmacs-rotate-replay-gain

Rotate through the MPD replay_gain_mode settings:

  1. off
  2. track
  3. album
  4. auto

3.3 Playlists Control

Command: mpdmacs-clear

Clear the current play queue.

Command: mpdmacs-load-playlist playlist

Load the saved PLAYLIST into the queue. If invoked interactively, the stored playlist will be read interactively.

mpdmacs-send-to-playlist: playlist

Send the current track to PLAYLIST. If invoked interactively, the target playlist will be read interactively.


3.4 The Current Track

mpdmacs-mode does offer a few, small, user-interface elements beyond commands & notifications.

Command: mpdmacs-show-current-song

Display information about the current song. This command will display the information in a dedicated buffer and display it. mpdmacs-show-current-song-hook is run in the buffer before display.

User Option: mpdmacs-current-song-buffer

The name of the buffer to use for current song information. The default value is “*Current Song*”.

User Option: defvar mpdmacs-show-current-song-hook

Normal hook run before mpdmacs-show-current-song returns. The hook will be invoked in the current song buffer.

In addition, when mpdmacs-mode is enabled, the current track will be displayed in the Emacs mode line. This can be customized or entirely disabled by customizing:

User Option: mpdmacs-mode-line-update-function

Function that will be invoked on current track change; if nil the mode line will not be updated.


3.5 Notifications

mpdmacs-mode defines a few hooks that will be run on certain player changes.

User Option: mpdmacs-player-state-changed-hook

Normal hook invoked when any change to the player or mixer state is detected.

User Option: mpdmacs-sticker-change-hook

Normal hook invoked when any change to the sticker database is detected.


4 Roadmap & Contributing

mpdmacs was first released in late 2020 and saw intermittent development over the next few years. In the fall of 2024 I decided to finally call this “1.0”, implying a certain level of stability (and notably the project will respect semver going forward).

Bugs & feature requests are welcome in the Issues section of the project. Also, you can just reach out directly at , or shoot a webmention to me at my web site.


Index


Function Index


Variable Index