Skip to main content

mpd-now-playable

PyPI version

This little Python program turns your MPD server into a now playable app on macOS. This enables your keyboard's standard media keys to control MPD, as well as more esoteric music control methods like the buttons on your Bluetooth headphones.

Table of Contents

Installation

The recommended way to install mpd-now-playable and its dependencies is with pipx:

pipx install mpd-now-playable
# or, if you'd like to use a separate cache service, one of these:
pipx install mpd-now-playable[redis]
pipx install mpd-now-playable[memcached]

Once pipx is done, the mpd-now-playable script should be available on your $PATH and ready to use.

Most likely, you'll want mpd-now-playable to stay running in the background as a launchd service. The CLI can install a per-user LaunchAgent for you:

mpd-now-playable install-launchagent

This writes ~/Library/LaunchAgents/me.00dani.mpd-now-playable.plist, bootstraps it with launchctl, and starts it immediately.

To replace an existing LaunchAgent plist:

mpd-now-playable install-launchagent --force

To remove it later:

mpd-now-playable uninstall-launchagent

You may override the launchd label in both commands with --label.

Configuration

You may not need any configuration! If you've got a relatively normal MPD setup on your local machine, mpd-now-playable ought to just work out of the box, as it uses sensible defaults. If you need to control a remote MPD server, or your MPD clients use a password, though, you'll need configuration for that use case.

Currently, mpd-now-playable can only be configured through environment variables. Command-line arguments are intentionally not supported, since your MPD password is among the supported settings and command-line arguments are not a secure way to pass secrets such as passwords into commands. Reading configuration from a file is secure, provided the file itself is kept secure, so mpd-now-playable may support a config file in future.

The following environment variables are read. The MPD_HOST and MPD_PORT variables are supported in the same way mpc uses them, but you can alternatively provide your password as a separate MPD_PASSWORD variable if you wish.

  • MPD_HOST - defaults to localhost, which should be fine for most users. If you want to control a remote MPD server, though, you can.
  • MPD_PORT - defaults to 6600, which will almost always be the correct port to use.
  • MPD_PASSWORD - has no default. Set this only if your MPD server expects a password. You can also provide a password by setting MPD_HOST=password@host, if you want to be consistent with how mpc works.

Additionally, mpd-now-playable caches your album artwork, by default simply in memory. It may be configured to use an external cache, and currently supports Redis and Memcached for this purpose. To use one of these, set the environment variable MPD_NOW_PLAYABLE_CACHE to an appropriate URL for your cache service:

  • For Redis, use something like redis://localhost:6379/0.
  • For Memcached, use something like memcached://localhost:11211.

You may provide a namespace query parameter to prefix cache keys if you wish, as well as a password query parameter if your service requires a password to access. As with your other environment variables, keep your cache password secure.

One simple secure way to set your environment variables is with a small wrapper script like this:

#!/bin/sh
export MPD_HOSTNAME=my.cool.mpd.host
export MPD_PORT=6700
export MPD_PASSWORD=swordfish
export MPD_NOW_PLAYABLE_CACHE='redis://localhost:6379/0?namespace=mpd-now-playable&password=fishsword'
exec mpd-now-playable

Make sure this wrapper script is only readable by you, with something like chmod 700!

If you're using launchd, you can point ProgramArguments in your plist at that wrapper script instead.

Limitations

mpd-now-playable is currently very specific to macOS. I did my best to keep the generic MPD and extremely Apple parts separate, but it definitely won't work with MPRIS2 or the Windows system media feature.

Chances are my macOS integration code isn't the best, either. This is the first project I've written using PyObjC and it took a lot of fiddling to get working.

I'm very open to contributions to fix any of these things, if you're interested in writing them!

Metadata

Release files for mpd-now-playable 1.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mpd-now-playable 1.6.2
File Size Uploaded
mpd_now_playable-1.6.2.tar.gz 37.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mpd-now-playable 1.6.2
File Interpreter ABI Platform
mpd_now_playable-1.6.2-py3-none-any.whl Python 3 none any Details

Total release size: 83.2 kB

Release files / mpd_now_playable-1.6.2.tar.gz

Download URL mpd_now_playable-1.6.2.tar.gz
Size 37.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6db9118892627994e804275e5787ee84d1ab165e4f7f2216261825699e36b68d
BLAKE2b-256 checksum
How to use checksums
c9edc7d5ff087edcde8b369e476cfecd9442688967dc7256d3c7ff97acac7621
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.29.0 CPython/3.13.15 Darwin/24.6.0

Release files / mpd_now_playable-1.6.2-py3-none-any.whl

Download URL mpd_now_playable-1.6.2-py3-none-any.whl
Size 45.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
feebe397ce19027896c6e1a873012e63caf2c4680ecbbba2f2793d36f93ccc54
BLAKE2b-256 checksum
How to use checksums
4177041169935bf5deb0f2f937d1ef7910eec095b10ce9488ee27b468c5e6d39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.29.0 CPython/3.13.15 Darwin/24.6.0

Release history Release notifications | RSS feed

This release

1.6.2 This release

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.4

2 release files

1.5.3

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page