emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/emms e02eaa784a 2/8: * emms-volume-pulse.el: reorganize


From: ELPA Syncer
Subject: [elpa] externals/emms e02eaa784a 2/8: * emms-volume-pulse.el: reorganize `emms-volume--pulse-get-volume'
Date: Sun, 5 Mar 2023 08:57:45 -0500 (EST)

branch: externals/emms
commit e02eaa784a385fecb3152637fe3daf8ba50bcd24
Author: Yoni Rabkin <yrk@gnu.org>
Commit: Yoni Rabkin <yrk@gnu.org>

    * emms-volume-pulse.el: reorganize `emms-volume--pulse-get-volume'
    
    The function `emms-volume--pulse-get-volume' is a mess. It has been
    reogranized so that the kludgy use of `let*' is more consistent, then
    the result is checked so that it doesn't throw out a useless error if
    the sink hasn't been configured.
---
 emms-volume-pulse.el | 44 ++++++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/emms-volume-pulse.el b/emms-volume-pulse.el
index d5c2a3e17d..cc8d158cb1 100644
--- a/emms-volume-pulse.el
+++ b/emms-volume-pulse.el
@@ -79,26 +79,30 @@ See full list of devices on your system by running
          (output
           (shell-command-to-string
            (concat "pactl list sinks" "|"
-                   "grep -E -e 'Sink' -e 'Name' -e '^[^a-zA-Z]*Volume'"))))
-    (string-to-number
-     (car
-      (reverse
-       (funcall
-        (if sink-number-p #'assq #'assoc)
-        emms-volume-pulse-sink
-        (mapcar (if sink-number-p 'identity 'cdr)
-                (cl-loop while
-                        (string-match
-                         (mapconcat #'identity
-                                    '(".*Sink[ \t]+\\#\\([0-9]+\\)"
-                                      ".*Name:[ \t]\\([^\n]+\\)"
-                                      ".*Volume:.*?\\([0-9]+\\)%.*\n?")
-                                    "\n")
-                         output)
-                        collect (list (string-to-number (match-string 1 
output))
-                                      (match-string 2 output)
-                                      (match-string 3 output))
-                        do (setq output (replace-match "" nil nil 
output))))))))))
+                   "grep -E -e 'Sink' -e 'Name' -e '^[^a-zA-Z]*Volume'")))
+        (volume-string
+         (car
+          (reverse
+           (funcall
+             (if sink-number-p #'assq #'assoc)
+             emms-volume-pulse-sink
+             (mapcar (if sink-number-p 'identity 'cdr)
+                     (cl-loop while
+                             (string-match
+                              (mapconcat #'identity
+                                         '(".*Sink[ \t]+\\#\\([0-9]+\\)"
+                                           ".*Name:[ \t]\\([^\n]+\\)"
+                                           ".*Volume:.*?\\([0-9]+\\)%.*\n?")
+                                         "\n")
+                              output)
+                             collect (list (string-to-number (match-string 1 
output))
+                                           (match-string 2 output)
+                                           (match-string 3 output))
+                             do (setq output (replace-match "" nil nil 
output)))))))))
+    (if volume-string
+       (string-to-number volume-string)
+      (error "cannot get volume from sink, check `emms-volume-pulse-sink'"))))
+
 
 ;;;###autoload
 (defun emms-volume-pulse-change (amount)



reply via email to

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