[Top][All Lists]

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

mocp.el 0.2

From: Andreas
Subject: mocp.el 0.2
Date: Wed, 08 Dec 2010 15:53:58 -0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)


This is a new release of mocp.el. Lots of new features added and bugs
fixed. Now you can see which song you play in your mini-buffer. 
Code Follows:
;;; mocp.el --- Managing Music On Console Player(mocp) from within Emacs

;; Author: Andreas Marschke <address@hidden>
;; Maintainer: Andreas Marschke <address@hidden>
;; Copyright (C) 2010, Andreas Marschke
;; Version: 0.2
;; Keywords: term, terminal, mocp, music
;; Compatibility: GNU Emacs 23.1.1

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;; Dependencies:
;; To use the full featureset of mocp.el you need the following things
;;    * multi-term - a mode based on term.el, for managing multiple terminal
;;      buffers in Emacs.(find it at:
;;    * either one of these IRC clients:
;;        - rcirc - an irc client for emacs  
;;        - erc - the Emacs iRC client
;;      Both are shipped with GNU Emacs 23.1(previous versions not tested) 
;;    * dired.el distributed with GNU Emacs
;;; Commentary:

;; This is a set of lisp commands that interface with the 
;; music on console player.

;; Todo:

;; - make more functions avaiable

;;; Code:

(require 'multi-term)
(require 'erc)
(require 'rcirc)

(defgroup mocp nil
  "A simple interface to mocp."
  :group 'mocp)

(defcustom mocp-volume-change-amount 5
  "Amount of % to change in volume when using `mocp-volume-up' or
`mocp-volume-down'. "
  :type 'integer
  :group 'mocp)

(defcustom mocp-ascii-art '(nil)
  "if non nil mocp will start drawing ascii characters when run in emacs."
  :type 'boolean
  :group 'mocp )

(defcustom mocp-debug '(nil)
  "if non-nil mocp will log to a file."
  :type 'boolean
  :group 'mocp)

(defcustom mocp-theme '(nil)
  "Use theme with this name."
  :type 'string
  :group 'mocp)

(defcustom mocp-cmdline-options '(nil)
  "used internally to group all customizations before passed to mocp"
  :type 'string)

(defun mocp-now-listening ()
   "mocp --format \" now listening to \\\"%song\\\" from the Album 
\\\"%album\\\" performed by: %artist\""))

;; (defun mocp-startup-options ()
;;   (if mocp-ascii-art
;;       (setq 'mocp-option
;;          (concat 'mocp-option " --ascii ")))
;;   (if mocp-debug
;;       (setq 'mocp-option
;;          (concat 'mocp-option " --debug ")))
;;   (if mocp-theme
;;       (setq 'mocp-option
;;          (concat 'mocp-option 
;;                  (format " --theme %s" (mocp-theme))))) )

(defun mocp ()
  "Music on console player"
  (let((multi-term-program "/usr/bin/mocp"))
  (rename-buffer "mocp" nil))

(defun mocp-next ()
  "Play next song in mocp's playlist"
  (shell-command "mocp --next")
  ;; a caching Race Condition would otherwise show the previous track
  (sleep-for 1 0)  
  (message  (mocp-now-listening))

(defun mocp-previous ()
  "Play previous song in mocp's playlist"
  (shell-command "mocp --previous ")
  ;; a caching Race Condition would otherwise show the previous track
  (sleep-for 1 0)  
  (message  (mocp-now-listening))

(defun mocp-stop ()
  "Stop playing."
  (shell-command "mocp --stop ")
  (message "MOCP Playback STOPPED")

(defun mocp-play ()
  "Start playing"
  (shell-command "mocp --play ")
  ;; a caching Race Condition would otherwise show the previous track
  (sleep-for 1 0)  
  (message  (mocp-now-listening))
(defun mocp-toggle-pp ()
  "Toggle playing/pausing"
  (shell-command "mocp --toggle-pause ")
(defun mocp-shuffle-on ()
  "Turn on shuffle."
  (shell-command "mocp --on shuffle")
(defun mocp-repeat-on ()
  "Turn on repeat."
  (shell-command "mocp --on repeat")

(defun mocp-autonext-on ()
  "Turn on autonext."
  (shell-command "mocp --on autonext")
(defun mocp-shuffle-off ()
  "Turn off shuffle."
  (shell-command "mocp --off shuffle")
(defun mocp-repeat-off ()
  "Turn off repeat."
  (shell-command "mocp --off repeat")
(defun mocp-autonext-off ()
  "Turn off autonext."
  (shell-command "mocp --off autonext")
(defun mocp-volume-up ()
  "increase volume by 5"
  (shell-command (format "mocp -v +%s" 5))
(defun mocp-volume-down ()
  (shell-command (format "mocp -v -%s" 5))

(defun mocp-append-file-to-playlist ()
  "append a file or directory to your mocp playlist."
  (shell-command (format "mocp -a '%s'" (dired-get-file-for-visit))))

(defun mocp-now-playing-irc-me ()
  "Post your currently playing song from mocp to the irc-channel"

  (if (eq major-mode 'rcirc-mode )
      (rcirc-cmd-me (mocp-now-listening)))

  (if (eq major-mode 'erc-mode )
      (erc-cmd-ME (mocp-now-listening)))

(provide 'mocp)

reply via email to

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