Skip to content
/ elmpd Public

A tight, ergonomic, async MPD client library in Emacs Lisp

License

Notifications You must be signed in to change notification settings

sp1ff/elmpd

Repository files navigation

elmpd

https://melpa.org/packages/elmpd-badge.svg https://stable.melpa.org/packages/elmpd-badge.svg https://github.com/sp1ff/elmpd/workflows/melpazoid/badge.svg

Introduction

elmpd is a tight, asynchronous, ergonomic MPD client library in Emacs Lisp.

License

This package is released under the GPL v3.

Prerequisites

Emacs 25.1.

Installing

The simplest way to install elmpd is from MELPA.

You can also install the package manually. Download the .tar file from Github or my personal page and say:

(package-install-file "elmpd-1.0.0.tar")

I’m now making GitHub releases that include Autotools source distributions:

curl -L --output elmpd-1.0.0.tar.gz https://github.com/sp1ff/elmpd/releases/download/1.0.0/elmpd-1.0.0.tar.gz  
tar xf elmpd-1.0.0.tar.gz && cd elmpd-1.0.0
./configure && make all check
sudo make install

And of course, you can just build from source:

git clone [email protected]:sp1ff/elmpd.git
cd elmpd
./bootstrap
./configure && make all check
sudo make install

Getting Started

User documentation is provided with the package, and may also be found here.

Motivation & Design Philosphy

Damien Cassou, the author of mpdel and libmpdel, reached out to ask “Why elmpd?” His question prompted me to clarify my thoughts around this project & I’ve adapted my response here.

I’ve looked at a few MPD clients, including mpdel. As I fine-tuned my workflow, however, I found myself wanting less functionality: rather than interacting with a fully-featured client, I just wanted to skip to the next song while I was editing code, for example. I customize my mode line heavily, and I wanted just a little bit of logic to add the current track to the mode line & keep it up-to-date. I have written a companion daemon to MPD that maintains ratings & play counts; I just needed a little function that would let me rate the current track while I was reading mail, for instance.

My next move was to read through a number of client libraries for inspiration, both in C & Emacs Lisp. Many of them had strong opinions on how one should talk to MPD. Having been programming MPD for a while I had come to appreciate its simplicity (after all, one can program it from bash by simply echo-ing commands to /dev/tcp/$host/$port). My experience with async Rust inspired me to see how simple I could make this. elmpd exports two primary functions: elmpd-connect & elmpd-send. Each connection consumes a socket & optionally a callback– that’s it; no buffer, no transaction queue. Put another way, if other libraries are Gnus (featureful, encourages you to read your e-mail in a certain way), then elmpd is Mailutils (small utilities that leave it up to the user to assemble them into something useful).

Status & Roadmap

The package has been stable for a few years now, so as of September 2024 I’m calling this “1.0”. It’s ripe for being used to build up a more caller-friendly API: something like (play) instead of

(let ((conn (elmpd-connect)))
  (elmpd-send conn "play"))

I’ve written a separate package, mpdmacs, that hopefully does so in a generic way.

Comments, suggestions & bug reports welcome in the issues or at [email protected].