Compare commits
3 Commits
55977bbc70
...
e9273dcf09
Author | SHA1 | Date | |
---|---|---|---|
e9273dcf09 | |||
5047d562c4 | |||
b54e3e4af6 |
@ -182,7 +182,7 @@ Note this interface may not work with all PipeWire versions.")
|
|||||||
(push item array)
|
(push item array)
|
||||||
(pw-cli--next-line))
|
(pw-cli--next-line))
|
||||||
(nreverse array)))))))
|
(nreverse array)))))))
|
||||||
|
|
||||||
(defun pw-cli--parse-properties ()
|
(defun pw-cli--parse-properties ()
|
||||||
(pw-cli--next-line)
|
(pw-cli--next-line)
|
||||||
(let ((end (or (save-excursion (re-search-forward "^ Object:" nil t))
|
(let ((end (or (save-excursion (re-search-forward "^ Object:" nil t))
|
||||||
|
13
pw-lib.el
13
pw-lib.el
@ -78,7 +78,7 @@ version, call `pw-lib-refresh' first."
|
|||||||
|
|
||||||
(defun pw-lib--object-info (object)
|
(defun pw-lib--object-info (object)
|
||||||
(cdr object))
|
(cdr object))
|
||||||
|
|
||||||
(defun pw-lib-object-value (object key &optional default)
|
(defun pw-lib-object-value (object key &optional default)
|
||||||
"Return PipeWire OBJECT value identified by KEY.
|
"Return PipeWire OBJECT value identified by KEY.
|
||||||
KEY is a string corresponding to a PipeWire value identifier.
|
KEY is a string corresponding to a PipeWire value identifier.
|
||||||
@ -86,6 +86,13 @@ If the given KEY doesn't exist in OBJECT, return DEFAULT."
|
|||||||
(or (cdr (assoc key (pw-lib--object-info object)))
|
(or (cdr (assoc key (pw-lib--object-info object)))
|
||||||
default))
|
default))
|
||||||
|
|
||||||
|
(defun pw-lib-properties (object)
|
||||||
|
"Return names of PipeWire OBJECT properties.
|
||||||
|
The returned value is a list of strings.
|
||||||
|
The corresponding values can be retrieved using `pw-lib-object-value'
|
||||||
|
function."
|
||||||
|
(cl-remove-if-not #'stringp (mapcar #'car (pw-lib--object-info object))))
|
||||||
|
|
||||||
(defun pw-lib-object-type (object)
|
(defun pw-lib-object-type (object)
|
||||||
"Return PipeWire type of OBJECT as a string.
|
"Return PipeWire type of OBJECT as a string.
|
||||||
E.g. \"Device\", \"Node\", \"Port\", \"Client\", ..."
|
E.g. \"Device\", \"Node\", \"Port\", \"Client\", ..."
|
||||||
@ -276,7 +283,7 @@ rather than using cached data to obtain the result."
|
|||||||
(if node-p
|
(if node-p
|
||||||
(cdr (assoc "volume" parameters))
|
(cdr (assoc "volume" parameters))
|
||||||
(nth port-id (cdr (assoc (if monitor-p "monitorVolumes" "channelVolumes") parameters)))))))
|
(nth port-id (cdr (assoc (if monitor-p "monitorVolumes" "channelVolumes") parameters)))))))
|
||||||
|
|
||||||
(defun pw-lib-set-volume (volume object &optional single-p)
|
(defun pw-lib-set-volume (volume object &optional single-p)
|
||||||
"Set the volume of PipeWire OBJECT to VOLUME.
|
"Set the volume of PipeWire OBJECT to VOLUME.
|
||||||
VOLUME must be an integer in the range 0-100.
|
VOLUME must be an integer in the range 0-100.
|
||||||
@ -318,7 +325,7 @@ otherwise set the current default sink or source."
|
|||||||
(pw-lib--set-default-node object stored-p))
|
(pw-lib--set-default-node object stored-p))
|
||||||
(_
|
(_
|
||||||
(error "Cannot set this kind of object as default."))))
|
(error "Cannot set this kind of object as default."))))
|
||||||
|
|
||||||
(provide 'pw-lib)
|
(provide 'pw-lib)
|
||||||
|
|
||||||
;;; pw-lib.el ends here
|
;;; pw-lib.el ends here
|
||||||
|
18
pw-ui.el
18
pw-ui.el
@ -96,6 +96,7 @@ The indicator is displayed only on graphical terminals."
|
|||||||
:group 'pipewire)
|
:group 'pipewire)
|
||||||
|
|
||||||
(defvar pipewire-buffer "*PipeWire*")
|
(defvar pipewire-buffer "*PipeWire*")
|
||||||
|
(defvar pipewire-properties-buffer "*PipWire-properties*")
|
||||||
|
|
||||||
(defun pw-ui--label (label)
|
(defun pw-ui--label (label)
|
||||||
(propertize (concat label ":") 'face 'pipewire-label))
|
(propertize (concat label ":") 'face 'pipewire-label))
|
||||||
@ -109,7 +110,7 @@ The indicator is displayed only on graphical terminals."
|
|||||||
'("application.name")
|
'("application.name")
|
||||||
(let ((prefix (concat (downcase type) ".")))
|
(let ((prefix (concat (downcase type) ".")))
|
||||||
(mapcar (lambda (suffix) (concat prefix suffix))
|
(mapcar (lambda (suffix) (concat prefix suffix))
|
||||||
'("description" "name"))))))
|
'("nick" "description" "name"))))))
|
||||||
(or (cl-find-if #'identity
|
(or (cl-find-if #'identity
|
||||||
(mapcar (lambda (p) (pw-lib-object-value object p))
|
(mapcar (lambda (p) (pw-lib-object-value object p))
|
||||||
description-properties))
|
description-properties))
|
||||||
@ -381,6 +382,20 @@ Otherwise ask for the Node to set as the default Node."
|
|||||||
(pw-ui--update))
|
(pw-ui--update))
|
||||||
(error "Nothing to set a profile for here")))
|
(error "Nothing to set a profile for here")))
|
||||||
|
|
||||||
|
(defun pipewire-properties ()
|
||||||
|
"Display properties of the object at the current point."
|
||||||
|
(interactive)
|
||||||
|
(if-let ((object (pw-ui--current-object)))
|
||||||
|
(progn
|
||||||
|
(pop-to-buffer pipewire-properties-buffer)
|
||||||
|
(let ((inhibit-read-only t))
|
||||||
|
(erase-buffer)
|
||||||
|
(dolist (p (sort (pw-lib-properties object) #'string-lessp))
|
||||||
|
(insert (format "%s: %s\n" p (pw-lib-object-value object p)))))
|
||||||
|
(goto-char (point-min))
|
||||||
|
(view-mode))
|
||||||
|
(error "No PipeWire object here")))
|
||||||
|
|
||||||
(defvar pipewire-mode-map
|
(defvar pipewire-mode-map
|
||||||
(let ((map (make-sparse-keymap)))
|
(let ((map (make-sparse-keymap)))
|
||||||
(define-key map "d" 'pipewire-set-default)
|
(define-key map "d" 'pipewire-set-default)
|
||||||
@ -391,6 +406,7 @@ Otherwise ask for the Node to set as the default Node."
|
|||||||
(define-key map "-" 'pipewire-decrease-volume)
|
(define-key map "-" 'pipewire-decrease-volume)
|
||||||
(define-key map "+" 'pipewire-increase-volume-single)
|
(define-key map "+" 'pipewire-increase-volume-single)
|
||||||
(define-key map "_" 'pipewire-decrease-volume-single)
|
(define-key map "_" 'pipewire-decrease-volume-single)
|
||||||
|
(define-key map " " 'pipewire-properties)
|
||||||
map))
|
map))
|
||||||
|
|
||||||
(define-derived-mode pipewire-mode special-mode "PW"
|
(define-derived-mode pipewire-mode special-mode "PW"
|
||||||
|
Loading…
Reference in New Issue
Block a user