aboutsummaryrefslogtreecommitdiff
path: root/lisp/emms-volume-amixer.el
diff options
context:
space:
mode:
authorWilliam Xu <william.xwl@gmail.com>2008-06-17 14:43:45 +0900
committerWilliam Xu <william.xwl@gmail.com>2008-06-17 14:43:45 +0900
commit67f5263943276faee0de53d947b6191205ae7a43 (patch)
tree0e67fe4722894a3d4dc9806fc506617c8a0c8a7d /lisp/emms-volume-amixer.el
parent964d7c3b354b66d0fba6f4eb7c2e058c2bfe2d59 (diff)
*.el -> lisp/*.el: Move lisp files into "lisp/" subdirectory.
Diffstat (limited to 'lisp/emms-volume-amixer.el')
-rw-r--r--lisp/emms-volume-amixer.el67
1 files changed, 67 insertions, 0 deletions
diff --git a/lisp/emms-volume-amixer.el b/lisp/emms-volume-amixer.el
new file mode 100644
index 0000000..6bee5ab
--- /dev/null
+++ b/lisp/emms-volume-amixer.el
@@ -0,0 +1,67 @@
+;;; emms-volume-amixer.el --- a mode for changing volume using amixer
+
+;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+;; Author: Martin Schoenmakers <aiviru@diamond-age.net>
+
+;; This file is part of EMMS.
+
+;; EMMS 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.
+;;
+;; EMMS is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with EMMS; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file defines a few simple functions to raise or lower the volume
+;; using amixer. It can be used stand-alone, though it's meant for usage
+;; with EMMS, particularly with emms-volume.el
+
+;;; History:
+
+;; May 30 2006: First cleanup and collation of amixer functions into a
+;; separate file for releasability.
+
+;;; Todo:
+
+;; There probably needs to be more configurability, which may in turn
+;; mean adding some more functions.
+;; Some of this could benefit from adding customize interfaces.
+
+;;; Code:
+
+(defcustom emms-volume-amixer-control "Master"
+ "The control to change the volume with.
+Controls includes \"Master\", \"PCM\", etc. For a full list of available
+controls, run `amixer controls' in a shell."
+ :type '(choice (const :tag "Master" "Master")
+ (const :tag "PCM" "PCM")
+ (string :tag "Something else: "))
+ :group 'emms-volume)
+
+;;;###autoload
+(defun emms-volume-amixer-change (amount)
+ "Change amixer master volume by AMOUNT."
+ (message "Playback channels: %s"
+ (with-temp-buffer
+ (when (zerop
+ (call-process "amixer" nil (current-buffer) nil
+ "sset" emms-volume-amixer-control
+ (format "%d%%%s" (abs amount)
+ (if (< amount 0) "-" "+"))))
+ (if (re-search-backward "\\[\\([0-9]+%\\)\\]" nil t)
+ (match-string 1))))))
+
+(provide 'emms-volume-amixer)
+
+;;; emms-volume-amixer.el ends here