Compare commits

...

2 Commits

2 changed files with 21 additions and 2 deletions

View File

@ -113,10 +113,16 @@ returned from `pw-lib-profiles'. "
(error "Index of %s profile of device %s not found" profile device-id))
(pw-access-set-profile pw-lib--accessor device-id index))))
(defun pw-lib-parent-node (object)
"Return parent node of `object'.
This is typically used for ports.
Behavior is undefined if `object' has no parent node."
(pw-lib-get-object (pw-lib-object-value object "node.id")))
(defun pw-lib--node (object)
(if (equal (pw-lib-object-type object) "Node")
object
(pw-lib-get-object (pw-lib-object-value object "node.id"))))
(pw-lib-parent-node object)))
(defun pw-lib--node-parameters (object-or-id &optional refresh)
(let* ((object (if (numberp object-or-id)

View File

@ -251,6 +251,11 @@ The indicator is displayed only on graphical terminals."
(propertize (make-string n-inactive mark)
'face `(:background ,pipewire-osd-volume-off-color)))))))
(defun pw-ui--update-muted (object muted-p)
(let ((object-name (pw-ui--object-name object))
(node-name (pw-ui--object-name (pw-lib-parent-node object))))
(pw-ui--update (format "%s in %s %s" object-name node-name (if muted-p "muted" "unmuted")))))
;;;###autoload
(defun pipewire-toggle-muted ()
"Switch mute status of an audio output or input.
@ -259,9 +264,17 @@ object. Otherwise apply it on the default audio sink."
(interactive)
(let* ((object (pw-ui--current-object t '("Node" "Port")))
(muted-p (pw-lib-toggle-mute object)))
(pw-ui--update (format "%s %s" (pw-ui--object-name object) (if muted-p "muted" "unmuted")))
(pw-ui--update-muted object muted-p)
(pw-ui--osd-volume object)))
;;;###autoload
(defun pipewire-toggle-microphone ()
"Switch mute status of the default audio input."
(interactive)
(let* ((object (car (pw-lib-default-capture-ports)))
(muted-p (pw-lib-toggle-mute object)))
(pw-ui--update-muted object muted-p)))
;;;###autoload
(defun pipewire-set-volume (volume &optional object single-p)
"Set volume of an audio output or input.