xwem-patches
[Top] [All Lists]

Summary for xwem--main--2.2--patch-44

From: Zajcev Evgeny <lg@xxxxxxxx>
Subject: Summary for xwem--main--2.2--patch-44
Date: Sun, 1 Jan 2006 19:14:07 +0300
Location: lg@xxxxxxxxxxxxxx http://arch.xwem.org/2005/

Revision: xwem--main--2.2--patch-44
Archive: lg@xxxxxxxxxxxxxx
Creator: Zajcev Evgeny <lg@xxxxxxxx>
Date: Sun Jan  1 19:14:00 MSK 2006
Standard-date: 2006-01-01 16:14:00 GMT
Modified-files: dockapp/xwem-mpd.el
New-patches: lg@xxxxxxxxxxxxxx/xwem--main--2.2--patch-44
    steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-19
Summary: mpd volume enhancements
Keywords: enhancement, internal, newfeature, user-visible

Merge from Steve that enhances volume related operations.  Here are
original comments:

Amongst other things, this changeset adds "unmute" being the opposite of
"mute".  When unmuting the volume it returns to the volume level that
existed before it was muted.  When the volume is muted, "MUTE" is
displayed in the dock.

You can now also specify the number of "steps" to increment/decrement the
volume with the `mpd-volume-{up,down}' functions.

Two new convenience functions have been added... `mpd-volume-max' &
`mpd-volume-min'. 

* dockapp/xwem-mpd.el (mpd-pre-mute-volume): New. Hold the volume setting
  prior to mute so unmute returns to the same volume.
  (mpd-volume-mute): Rewrite as a xwem-command so it can use a prefix arg
  to unmute.  Also use the mpd command `setvol' instead of `volume'
  because the latter is a deprecated command.
  (mpd-volume-up): Rewrite as a xwem-command, accept numeric prefix arg
  to specify the "steps" to increment the volume.  Use `setvol' instead
  of `volume'.
  (mpd-volume-down): Ditto, except we're decreasing the volume of
  course. 
  (mpd-volume-max): New.  Convenience function to set volume to maximum.
  (mpd-volume-min): New.  Convenience function to set volume to minimum.
  (mpd-muted-p): New.  Return non-nil when volume is at zero.
  (xwem-mpd-osd-setup): Use it.
  (xwem-mpd-osd-update): Ditto.

* added files

    {arch}/xwem/xwem--main/xwem--main--2.2/lg@xxxxxxxxxxxxxx/patch-log/patch-44
    
{arch}/xwem/xwem--steve/xwem--steve--2.2/steve@xxxxxxxxxxxxxx/patch-log/patch-19

* modified files

--- orig/dockapp/xwem-mpd.el
+++ mod/dockapp/xwem-mpd.el
@@ -80,7 +80,9 @@
     (lyrics :place bottom-right :depth 0 :icon "mini-lyrics.xpm")
     (volume :place right :depth 1 :font "fixed" :color "white")
     (state :place center :depth 1 :font 
"-*-helvetica-bold-r-*-*-20-*-*-*-*-*-*-*"
-           :color "red3" :format (or (and (mpd-stopped-p) "STOPPED") (and 
(mpd-paused-p) "PAUSED"))))
+           :color "red3" :format (or (and (mpd-stopped-p) "STOPPED")
+                                    (and (mpd-paused-p) "PAUSED")
+                                    (and (mpd-muted-p) "MUTE"))))
   "Mpd dockapp configuration.
 :place is not yet implemented."
   :type 'list
@@ -169,6 +171,11 @@
 (defvar **mpd-var-volume* nil)
 (defvar **mpd-var-xfade* nil)
 
+(defvar mpd-pre-mute-volume nil
+  "Holds the value of `**mpd-var-volume* prior to muting.
+The purpose of this is so that when you unmute, it goes back to the
+volume you had it set to before you muted.")
+
 (defvar mpd-this-command nil
   "The mpd command currently executing.
 Useful to use in `mpd-after-command-hook' hooks.")
@@ -193,6 +200,8 @@
   (string= **mpd-var-state* "stop"))
 (defun mpd-paused-p ()
   (string= **mpd-var-state* "pause"))
+(defun mpd-muted-p ()
+  (zerop (string-to-number **mpd-var-volume*)))
 
 ;; (mpd-songpos)
 (defun mpd-songpos ()
@@ -202,17 +211,52 @@
         (cons (string-to-int a) (string-to-int b)))
     (cons 0 1)))                        ; todo?
 
-(define-mpd-command mpd-volume-up ()
-  (interactive)
-  (mpd-send "volume +2"))
+(define-xwem-command mpd-volume-up (step)
+  "Increase the volume by STEP increments.
+STEP can be given via numeric prefix arg and defaults to 1 if omitted."
+  (xwem-interactive "p")
+  (let* ((oldvol (string-to-number **mpd-var-volume*))
+        (newvol (+ oldvol step))
+        (mpd-this-command 'mpd-volume-down))
+    (when (>= newvol 100)
+      (setq newvol 100))
+    (mpd-send "setvol %d" newvol)
+    (run-hooks 'mpd-after-command-hook)))
+
+(define-xwem-command mpd-volume-down (step)
+  "Decrease the volume by STEP increments.
+STEP can be given via numeric prefix arg and defaults to 1 if omitted."
+  (xwem-interactive "p")
+  (let* ((oldvol (string-to-number **mpd-var-volume*))
+        (newvol (- oldvol step))
+        (mpd-this-command 'mpd-volume-down))
+    (when (<= newvol 0)
+      (setq newvol 0))
+    (mpd-send "setvol %d" newvol)
+    (run-hooks 'mpd-after-command-hook)))
+
+(define-xwem-command mpd-volume-mute (&optional unmute)
+  "Mute the volume.
+With prefix arg, UNMUTE, let the tunes blast again."
+  (xwem-interactive "P")
+  (if unmute
+      (mpd-send "setvol %s" mpd-pre-mute-volume)
+    (setq mpd-pre-mute-volume **mpd-var-volume*)
+    (mpd-send "setvol 0"))
+  (let ((mpd-this-command 'mpd-volume-mute))
+    (run-hooks 'mpd-after-command-hook)))
 
-(define-mpd-command mpd-volume-down ()
+(define-mpd-command mpd-volume-max ()
+  "Set volume to maximum."
   (interactive)
-  (mpd-send "volume -2"))
+  (mpd-send "setvol 100"))
 
-(define-mpd-command mpd-volume-mute ()
+(define-mpd-command mpd-volume-min ()
+  "Set volume to minimum.
+Sets state to \"muted\" by side effect."
   (interactive)
-  (mpd-send "volume -100"))
+  (setq mpd-pre-mute-volume **mpd-var-volume*)
+  (mpd-send "setvol 0"))
 
 (define-mpd-command mpd-seek (time)
   "Seek current track to TIME."
@@ -472,7 +516,7 @@
             (xwem-osd-instance-put-prop osin 'lyric-hidden t)))
         
         ;; State
-        (if (or (mpd-stopped-p) (mpd-paused-p))
+        (if (or (mpd-stopped-p) (mpd-paused-p) (mpd-muted-p))
           (let* ((txt (eval (plist-get st-plist :format)))
                  (fnt (X-Font-get (xwem-osd-xdpy xwem-mpd-osd)
                                   (plist-get st-plist :font)))




<Prev in Thread] Current Thread [Next in Thread>
  • Summary for xwem--main--2.2--patch-44, Zajcev Evgeny <=