Allow applying pipewire-set-default on a whole device
This commit is contained in:
parent
f6035e710f
commit
2e63bcff13
18
pw-lib.el
18
pw-lib.el
@ -219,15 +219,25 @@ otherwise set the volume to the same value for all the related channels."
|
|||||||
(make-list (length orig-value) float-volume))))))
|
(make-list (length orig-value) float-volume))))))
|
||||||
(pw-access-set-properties pw-lib--accessor node-id (list (cons property value))))))
|
(pw-access-set-properties pw-lib--accessor node-id (list (cons property value))))))
|
||||||
|
|
||||||
(defun pw-lib-set-default (object stored-p)
|
(defun pw-lib--set-default-node (object stored-p)
|
||||||
"Set PipeWire OBJECT as the default sink or source.
|
|
||||||
If STORED-P is non-nil, set the stored default sink or source,
|
|
||||||
otherwise set the current default sink or source."
|
|
||||||
(let ((suffix (mapconcat #'downcase
|
(let ((suffix (mapconcat #'downcase
|
||||||
(split-string (pw-lib-object-value object "media.class") "/")
|
(split-string (pw-lib-object-value object "media.class") "/")
|
||||||
"."))
|
"."))
|
||||||
(prefix (if stored-p "default.configured." "default."))
|
(prefix (if stored-p "default.configured." "default."))
|
||||||
(node-name (pw-lib-object-value object "node.name")))
|
(node-name (pw-lib-object-value object "node.name")))
|
||||||
(pw-access-set-default pw-lib--accessor (concat prefix suffix) node-name)))
|
(pw-access-set-default pw-lib--accessor (concat prefix suffix) node-name)))
|
||||||
|
|
||||||
|
(defun pw-lib-set-default (object stored-p)
|
||||||
|
"Set PipeWire OBJECT as the default sink or source.
|
||||||
|
If STORED-P is non-nil, set the stored default sink or source,
|
||||||
|
otherwise set the current default sink or source."
|
||||||
|
(pcase (pw-lib-object-type object)
|
||||||
|
("Device"
|
||||||
|
(dolist (node (pw-lib-children (pw-lib-object-id object) (pw-lib-bindings) "Node"))
|
||||||
|
(pw-lib--set-default-node node stored-p)))
|
||||||
|
("Node"
|
||||||
|
(pw-lib--set-default-node object stored-p))
|
||||||
|
(_
|
||||||
|
(error "Cannot set this kind of object as default."))))
|
||||||
|
|
||||||
(provide 'pw-lib)
|
(provide 'pw-lib)
|
||||||
|
3
pw-ui.el
3
pw-ui.el
@ -212,9 +212,10 @@ object. Otherwise apply it on the default audio sink."
|
|||||||
(defun pipewire-set-default ()
|
(defun pipewire-set-default ()
|
||||||
"Set default sink or source.
|
"Set default sink or source.
|
||||||
If on a Node in a PipeWire buffer, apply it on the given object.
|
If on a Node in a PipeWire buffer, apply it on the given object.
|
||||||
|
If on a Device, apply it on all its nodes.
|
||||||
Otherwise ask for the Node to set as the default Node."
|
Otherwise ask for the Node to set as the default Node."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((object (or (pw-ui--current-object nil '("Node"))
|
(let ((object (or (pw-ui--current-object nil '("Device" "Node"))
|
||||||
(let* ((default-node-ids (mapcar #'cdr (pw-lib-default-nodes)))
|
(let* ((default-node-ids (mapcar #'cdr (pw-lib-default-nodes)))
|
||||||
(nodes (cl-remove-if
|
(nodes (cl-remove-if
|
||||||
#'(lambda (n) (member (pw-lib-object-id n) default-node-ids))
|
#'(lambda (n) (member (pw-lib-object-id n) default-node-ids))
|
||||||
|
Loading…
Reference in New Issue
Block a user