Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jorenvo/simple-mpc
A GNU Emacs frontend to mpc.
https://github.com/jorenvo/simple-mpc
emacs emacs-lisp mpc mpd
Last synced: 3 months ago
JSON representation
A GNU Emacs frontend to mpc.
- Host: GitHub
- URL: https://github.com/jorenvo/simple-mpc
- Owner: jorenvo
- License: gpl-3.0
- Created: 2015-03-29T11:12:52.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-24T03:27:39.000Z (almost 2 years ago)
- Last Synced: 2024-06-17T06:34:47.141Z (5 months ago)
- Topics: emacs, emacs-lisp, mpc, mpd
- Language: Emacs Lisp
- Homepage:
- Size: 148 KB
- Stars: 39
- Watchers: 4
- Forks: 12
- Open Issues: 2
-
Metadata Files:
- Readme: README.org
- License: COPYING
Awesome Lists containing this project
- awesome-starred - simple-mpc - A GNU Emacs frontend to mpc. (Emacs Lisp)
README
* simple-mpc [[http://melpa.org/#/simple-mpc][file:http://melpa.org/packages/simple-mpc-badge.svg]]
A GNU Emacs major mode that acts as a front end to [[http://www.musicpd.org/clients/mpc/][mpc]].
[[./screenshot.png]]
** Requirements
- [[https://www.gnu.org/software/emacs/][GNU Emacs >=24]]
- [[http://www.musicpd.org/][Music Player Daemon]] or [[https://www.mopidy.com/][Mopidy]]
- [[http://www.musicpd.org/clients/mpc/][mpc]]
** Installation
*** MELPA
The easiest way to install is through [[http://melpa.org/][MELPA]].To do this add MELPA to your =package-archives= list if you have not
yet done so:#+BEGIN_SRC lisp
(require 'package) ;; You might already have this line
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/"))
(package-initialize) ;; You might already have this line
#+END_SRCThen install the package through either =M-x list-packages= or by just
running =M-x package-install simple-mpc=.
*** Manual
- Clone the repository
- Add it to your emacs init:
#+BEGIN_SRC lisp
(add-to-list 'load-path "path/to/simple-mpc")
(require 'simple-mpc)
#+END_SRC
** Usage
*** Quickstart
Start with =M-x simple-mpc=. The rest of the keybindings now appear in
a buffer. Configuration can be done with =M-x customize-group
simple-mpc=. Viewing the current playlist and querying the database is
done with =c= and =s= respectively. Most commands (like
=simple-mpc-query-add= and =simple-mpc-delete=) respect the region.
*** Structure
Simple-mpc consists of three 'views', two of which have their own
minor mode that implements specific extra functionality:|------------------+-----------------+----------------------------------|
| view | major mode | minor mode |
|------------------+-----------------+----------------------------------|
| main | simple-mpc-mode | / |
| query | simple-mpc-mode | simple-mpc-query-mode |
| current playlist | simple-mpc-mode | simple-mpc-current-playlist-mode |
|------------------+-----------------+----------------------------------|simple-mpc-mode is always active and contains the most common
bindings. Additional functionality is added with minor modes. Someone
who does not like the interface can use =simple-mpc-query-mode= and
=simple-mpc-current-playlist-mode= directly.
*** Bindings
Bindings can be viewed with =describe-mode= (=C-h m=) but are listed
below for completeness:
**** simple-mpc-mode
|-----+-------------------------------------|
| key | function |
|-----+-------------------------------------|
| =t= | simple-mpc-toggle |
| =n= | simple-mpc-next |
| =p= | simple-mpc-prev |
| =f= | simple-mpc-seek-forward |
| =b= | simple-mpc-seek-backward |
| =c= | simple-mpc-view-current-playlist |
| =C= | simple-mpc-clear-current-playlist |
| =S= | simple-mpc-shuffle-current-playlist |
| =l= | simple-mpc-load-playlist |
| =s= | simple-mpc-query |
| =q= | simple-mpc-quit |
|-----+-------------------------------------|
**** simple-mpc-query-mode
|--------------+-------------------------------|
| key | function |
|--------------+-------------------------------|
| =q= | simple-mpc-query-quit |
| =S= | simple-mpc-query-sort |
| == | simple-mpc-query-add |
| == | simple-mpc-query-add-and-play |
|--------------+-------------------------------|
**** simple-mpc-current-playlist-mode
|------------+----------------------------------|
| key | function |
|------------+----------------------------------|
| =d= | simple-mpc-delete |
| =q= | simple-mpc-current-playlist-quit |
| == | simple-mpc-play-current-line |
|------------+----------------------------------|
*** Hook
You can use a hook like this to ensure that mpd is running when you
open simple-mpc:#+begin_src emacs-lisp
(add-hook 'simple-mpc-mode-hook (lambda () (my/mpd-start)))(defun my/mpd-start ()
"Start MPD if it's not already running and check, then update the MPD database."
(interactive)
(if (= 0 (call-process "sh" nil nil nil "-c" "pgrep mpd"))
(message "MPD was already running.")
(shell-command "mpd")
(my/mpd-update)
(message "MPD started.")))(defun my/mpd-kill ()
"Kill MPD."
(interactive)
(call-process "killall" nil nil nil "mpd")
(message "MPD killed."))(defun my/mpd-update ()
"Updates the MPD database synchronously."
(interactive)
(call-process "mpc" nil nil nil "update")
(message "MPD database updated."))
#+end_src
** Configuration
Configuring simple-mpc can be done entirely through the =simple-mpc=
customization group (=M-x customize-group simple-mpc=).When using Mopidy as a server setting =simple-mpc-playlist-format= is
recommended, the default output from =mpc search= won't be very
descriptive otherwise. The following configuration works well mopidy
(note that the whitespace between the metadata delimiters and the
separator itself are TAB characters (=C-q =), *not spaces*):#+BEGIN_SRC lisp
(custom-set-variables
...
'(simple-mpc-playlist-format "%artist% %album% %title% %file%")
'(simple-mpc-table-separator " ")
...)
#+END_SRC
** History
This mode was inspired by [[https://github.com/pft/mingus][mingus]] written by Niels Giesen and parts of
the interface were inspired by [[http://www.djcbsoftware.nl/code/mu/mu4e.html][mu4e]] written by Dirk-Jan C. Binnema. I
used mingus for > 4 years and was mostly happy with it, but
occasionally there were bugs and interface choices that I disagreed
with. After looking through the source code in an attempt to fix these
issues I came to the conclusion that it would be better to implement
my own mode. A big reason for this decision was the fact that mingus
uses its own MPD library implementation called [[https://github.com/pft/mingus/blob/master/libmpdee.el][libmpdee.el]], which I
expect contain some obscure bugs. I think it is a better choice to
instead take advantage of mpc, a small program that is maintained by
MPD developers and implements more than libmpdee.el. On top of that it
makes the major mode much smaller and easier to maintain. Currently
simple-mpc consists of ~300 LOC versus ~5000 LOC for mingus (mingus
does have more features though).GNU Emacs also contains [[http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/mpc.el][mpc.el]] written by Stefan Monnier. It's
interesting but wasn't really what I was looking for, partly because
of its interface (inspired by [[https://wiki.gnome.org/Apps/Rhythmbox][Rhythmbox]]), and partly because it's not
particularly well documented.
** Todo
- add a way to combine multiple search terms e.g. mpc search artist a album b