From e9273dcf09813f4f729ac7fbfa5af2dca00a495b Mon Sep 17 00:00:00 2001 From: Milan Zamazal Date: Sat, 2 Jul 2022 09:43:54 +0200 Subject: [PATCH] New command pipewire-properties --- pw-lib.el | 7 +++++++ pw-ui.el | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/pw-lib.el b/pw-lib.el index ea8ad65..a012dfa 100644 --- a/pw-lib.el +++ b/pw-lib.el @@ -86,6 +86,13 @@ If the given KEY doesn't exist in OBJECT, return DEFAULT." (or (cdr (assoc key (pw-lib--object-info object))) 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) "Return PipeWire type of OBJECT as a string. E.g. \"Device\", \"Node\", \"Port\", \"Client\", ..." diff --git a/pw-ui.el b/pw-ui.el index 0eb65fc..6f3cbdc 100644 --- a/pw-ui.el +++ b/pw-ui.el @@ -96,6 +96,7 @@ The indicator is displayed only on graphical terminals." :group 'pipewire) (defvar pipewire-buffer "*PipeWire*") +(defvar pipewire-properties-buffer "*PipWire-properties*") (defun pw-ui--label (label) (propertize (concat label ":") 'face 'pipewire-label)) @@ -381,6 +382,20 @@ Otherwise ask for the Node to set as the default Node." (pw-ui--update)) (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 (let ((map (make-sparse-keymap))) (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-increase-volume-single) (define-key map "_" 'pipewire-decrease-volume-single) + (define-key map " " 'pipewire-properties) map)) (define-derived-mode pipewire-mode special-mode "PW"