EOS: Music Module
Table of Contents
(provide 'eos-music)
I use MPD to stream music, not only because if uses far less CPU, but also because there is a nice Emacs interface to it.
Ensure that Emacs knows where MPD is listening
(setenv "MPD_HOST" "localhost") (setenv "MPD_PORT" "6600")
MPD configuration
Configure MPD to be pointing to our local machine
music_directory "/home/hinmanm/Music" playlist_directory "/home/hinmanm/.mpd/playlists" db_file "/home/hinmanm/.mpd/mpd.db" log_file "/home/hinmanm/.mpd/mpd.log" state_file "/home/hinmanm/.mpd/mpdstate" port "6600" bind_to_address "127.0.0.1"
Configure the address and port in Bash
export MPD_HOST=localhost export MPD_PORT=6600
We also need to set up the systemd service for MPD
[Unit] Description=MPD [Service] Type=simple ExecStart=/usr/bin/mpd --no-daemon /home/hinmanm/.mpd.conf ExecStop=/usr/bin/pkill mpd Environment=DISPLAY=:0 Restart=always [Install] WantedBy=default.target
Install the required software
deb-install mpd deb-install mpc rpm-install mpd rpm-install mpc mkdir -p ~/Music mkdir -p ~/.mpd/playlists ln -svf $PWD/out/mpd.conf ~/.mpd.conf cp -fv $PWD/out/mpd.service ~/.config/systemd/user/mpd.service systemctl --user daemon-reload systemctl --user enable mpd systemctl --user start mpd
Mingus MPD frontend
I haven't actually used this, but we can install it to try it out…
(use-package mingus :ensure t)
Hydra Music Controller
Mingus is a nifty little minimalist MPD frontend, but it doesn't ship with any keybindings out of the box. I'd like global MPD bindings, and this goes a long way to get there.
(defhydra eos/hydra-mpd nil "MPD Actions" ("p" (progn (save-window-excursion (async-shell-command "mpc toggle" (get-buffer-create "*tmp*")))) "Play/Pause") ("/" mingus-search "Search" :exit t) ("c" (message "Currently Playing: %s" (shell-command-to-string "mpc status")) "Currently Playing") ("s" mingus "Show Mingus" :exit t) ("m" mingus "Mingus" :exit t) ("<" (progn (require 'mpc) (mpc-prev) (message "Currently Playing: %s" (shell-command-to-string "mpc status"))) "Previous") (">" (progn (require 'mpc) (mpc-next) (message "Currently Playing: %s" (shell-command-to-string "mpc status"))) "Next") ("+" (dotimes (i 5) (mingus-vol-up)) "Louder") ("-" (dotimes (i 5) (mingus-vol-down)) "Quieter") ("n" (ansi-term (executable-find "ncmpcpp")) "ncmpcpp" :exit t) ("q" nil "Quit"))
This actually gets bound in eos-core.org