From 5e336027c5b09e30c257cb06622abba085ba01cb Mon Sep 17 00:00:00 2001 From: Ivy Foster Date: Mon, 17 Mar 2008 16:32:31 -0400 Subject: [PATCH] Reformatted contrib/amixer.lisp to work with new defcommand syntax. --- contrib/amixer.lisp | 68 +++++++++++++++++++++++++++++++++----------------- 1 files changed, 45 insertions(+), 23 deletions(-) diff --git a/contrib/amixer.lisp b/contrib/amixer.lisp index 6a8ba60..7c16907 100644 --- a/contrib/amixer.lisp +++ b/contrib/amixer.lisp @@ -27,31 +27,54 @@ ;;; ;;; In your ~/.stumpwmrc -(defvar +amixer-channels+ '("PCM" "Master" "Headphone")) -(defvar +amixer-options+ '(nil "1+" "1-")) +(defun volcontrol (channel amount) + (let ((percent + (parse-integer + (run-shell-command + (concat "amixer sset " channel " " (or amount "toggle") + "| sed -n 's/^.*\\[\\([[:digit:]]\\+\\)%\\].*$/\\1/p' | head -1") + t)))) + (message + (concat "Mixer: " channel " " (or amount "toggled") (format nil "~C^B~A%" #\Newline percent) "^b [^[^7*" + (bar percent 50 #\# #\:) "^]]")))) -;; A command to create volume-control commands -(defun def-volcontrol (channel amount) - "Commands for controling the volume" - (define-stumpwm-command - (concat "amixer-" channel "-" (or amount "toggle")) () - (let ((percent - (parse-integer - (run-shell-command - (concat "amixer sset " channel " " (or amount "toggle") "| sed -n 's/^.*\\[\\([[:digit:]]\\+\\)%\\].*$/\\1/p' | head -1") t)))) - (message - (concat "Mixer: " channel " " (or amount "toggled") (format nil "~C^B~A%" #\Newline percent) "^b [^[^7*" - (bar percent 50 #\# #\:) "^]]"))))) +(defcommand amixer-PCM-1- () () + "Lowers PCM volume" + (volcontrol "PCM" "1-")) -(let ((channels +amixer-channels+)) - (loop while channels do - (let ((options +amixer-options+)) - (loop while options do - (def-volcontrol (car channels) (car options)) - (setq options (cdr options)))) - (setq channels (cdr channels)))) +(defcommand amixer-PCM-1+ () () + "Raises PCM volume" + (volcontrol "PCM" "1+")) -(define-stumpwm-command "amixer-sense-toggle" () +(defcommand amixer-PCM-toggle () () + "Un/mutes PCM volume" + (volcontrol "PCM" nil)) + +(defcommand amixer-Master-1- () () + "Lowers Master volume" + (volcontrol "Master" "1-")) + +(defcommand amixer-Master-1+ () () + "Raises Master volume" + (volcontrol "Master" "1+")) + +(defcommand amixer-Master-toggle () () + "Un/mutes Master volume" + (volcontrol "Master" nil)) + +(defcommand amixer-Headphone-1- () () + "Lowers Headphone volume" + (volcontrol "Headphone" "1-")) + +(defcommand amixer-Headphone-1+ () () + "Raises Headphone volume" + (volcontrol "Headphone" "1+")) + +(defcommand amixer-Headphone-toggle () () + "Un/mutes Headphone volume" + (volcontrol "Headphone" nil)) + +(defcommand amixer-sense-toggle () () (message (concat "Headphone Jack Sense toggled" (run-shell-command "amixer sset 'Headphone Jack Sense' toggle" t)))) @@ -72,4 +95,3 @@ (define-key *top-map* (kbd "M-XF86AudioRaiseVolume") "amixer-Headphone-1+") (define-key *top-map* (kbd "M-XF86AudioMute") "amixer-Headphone-toggle") (define-key *top-map* (kbd "S-XF86AudioMute") "amixer-sense-toggle") - -- 1.5.5