emms-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Example Emms setups


From: Fran Burstall (Gmail)
Subject: Re: Example Emms setups
Date: Sun, 20 Dec 2020 20:18:17 +0000



On Sun, 20 Dec 2020 at 03:19, Yoni Rabkin <yoni@rabkins.net> wrote:

Hello all,

I'd like to add to the Emms manual a more robust example of an Emms
setup. The manual has an example simply setup, but I think it would be
nice to also have an example of how a more mature setup looks like.

Anyone who would like to, please send in examples of your Emms setups,
or parts of them, so that I can choose interesting bits to add to the
example I'm planning for the manual.

Main interest here is that I use the fashionable use-package macro:

(use-package emms-setup
  :if (daemonp)
  :load-path "~/projects/emms"
  :init
  ;; stolen from: http://mbork.pl/2015-12-05_Emms_and_hydra
 
  (defun emms-status (&optional print-message)
    "Returns the status of Emms - one of `playing', `paused' and
`stopped'.  If called interactively, prints an appropriate
message.  If called from Lisp code, returns an appropriate
symbol."
    (interactive "p")
    (let ((status
           (if emms-player-playing-p
               (if emms-player-paused-p
                   'paused 'playing)
             'stopped)))
      (if print-message
          (message "Emms status: %s." status)
status)))

  (defun emms-status-track (&optional print-message)
    "Return or print in the echo area the status of Emms.  If playing,
include the current track info."
    (interactive "p")
    (let ((status (emms-status))
          (fun (if print-message #'message #'format)))
      (if (eq status 'stopped)
          (funcall fun "Emms stopped.")
(funcall fun "Emms %s, current track: %s."
status
(emms-track-description
                  (emms-playlist-current-selected-track))))))

  (defhydra hydra-emms (:timeout 6 :columns 4)
    "
Emms: %s(emms-status-track)
"
    ("SPC" emms-pause "Play/Pause")
    ("s" emms-stop "Stop")
    ("<left>" emms-previous "Backward")
    ("<right>" emms-next "Forward")
    ("<down>" emms-volume-lower "Volume down")
    ("<up>" emms-volume-raise "Volume up")
    ("+" emms-add-directory "Add directory")
    ("C-+" emms-add-directory-tree "Add directory tree")
    ("RET" emms "Show playlist")
    ("r" emms-shuffle "Shuffle tracks")
    ("q" ignore "Exit" :exit t))

  (global-set-key (kbd "C-c e") 'hydra-emms/body)

  (defun emms-add-files-to-cache ()
    "Search music library for new tracks and add them to the cache."
    (interactive)
    (mapc (lambda (file) (emms-track 'file file))
 (seq-filter #'(lambda (path) (not (gethash path emms-cache-db)))
     (directory-files-recursively "/media/shared/music" "\.mp3$\\|\.wav$\\|\.aif$\\|\.ogg"))))
  ;; track listings
  (defun pad-string (str len)
    "Return a string of length LEN starting with STR, truncating or padding as necessary."
    (let* ((str-len (length str))
  (extra-len (- len str-len)))
      (if (>= extra-len 0)
 (concat str (make-string extra-len ? ))
(concat (substring str 0 (- len 3)) "..."))))

  (defun my-track-description-function (track)
    "Detailed track listing for TRACK."
    (let* ((artist (emms-track-get track 'info-artist))
  (album (emms-track-get track 'info-album))
  (title (emms-track-get track 'info-title))
  (type (emms-track-get track 'type))
  (name (emms-track-get track 'name))
  (year (emms-track-get-year track)))
      (if (eq type 'file)
 (concat
  (pad-string (if artist artist "Unknown artist") 30)
  "    "
  (pad-string title 30)
  "    "
  (pad-string (if album album "") 30)
  "    "
  year)
(concat (symbol-name type) ":" name)))
    )

  (add-hook 'emms-playlist-mode-hook
   (lambda () (setq-local emms-track-description-function #'my-track-description-function)))
 
  :config
  (emms-all)
  (emms-default-players)
  (setq emms-source-file-default-directory "/media/shared/music/")
  (put 'emms-browser-delete-files 'disabled nil)
  ;; tags
  (require 'emms-info-libtag)
  (setq emms-info-functions '(emms-info-libtag))
  (setq emms-info-libtag-known-extensions
(regexp-opt '("mp3" "mp4" "m4a" "ogg" "flac" "spx" "wma" "aif")))
 
  ;; notifications
  (require 'emms-dbus)
  (emms-dbus-enable)
  ;; covers
  (setq emms-browser-covers #'emms-browser-cache-thumbnail-async)
  (setq emms-browser-thumbnail-small-size 64)
  (setq emms-browser-thumbnail-medium-size 128)
  ;; filters
  (emms-browser-make-filter "all" #'ignore)
  (emms-browser-make-filter "recent"
     (lambda (track) (< 30
        (time-to-number-of-days
  (time-subtract (current-time)
        (emms-info-track-file-mtime track))))))
  (emms-browser-set-filter (assoc "all" emms-browser-filters))
  ;; history
  (emms-history-load)
  ;; libre-fm
  (emms-librefm-scrobbler-enable))

---Fran

reply via email to

[Prev in Thread] Current Thread [Next in Thread]