Compare commits

...

5 Commits

4 changed files with 23 additions and 15 deletions

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2022 Milan Zamazal <pdm@zamazal.org> ;; Copyright (C) 2022 Milan Zamazal <pdm@zamazal.org>
;; Author: Milan Zamazal <pdm@zamazal.org> ;; Author: Milan Zamazal <pdm@zamazal.org>
;; Package-Version: 1 ;; Version: 1
;; Package-Requires: ((emacs "25.1")) ;; Package-Requires: ((emacs "25.1"))
;; Keywords: multimedia ;; Keywords: multimedia
;; URL: https://git.zamazal.org/pdm/pipewire-0 ;; URL: https://git.zamazal.org/pdm/pipewire-0

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2022 Milan Zamazal <pdm@zamazal.org> ;; Copyright (C) 2022 Milan Zamazal <pdm@zamazal.org>
;; Author: Milan Zamazal <pdm@zamazal.org> ;; Author: Milan Zamazal <pdm@zamazal.org>
;; Package-Version: 1 ;; Version: 1
;; Package-Requires: ((emacs "25.1")) ;; Package-Requires: ((emacs "25.1"))
;; Keywords: multimedia ;; Keywords: multimedia
;; URL: https://git.zamazal.org/pdm/pipewire-0 ;; URL: https://git.zamazal.org/pdm/pipewire-0
@ -39,6 +39,8 @@
(require 'eieio) (require 'eieio)
;;; Code:
(defclass pw-accessor () (defclass pw-accessor ()
() ()
:documentation :documentation

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2022 Milan Zamazal <pdm@zamazal.org> ;; Copyright (C) 2022 Milan Zamazal <pdm@zamazal.org>
;; Author: Milan Zamazal <pdm@zamazal.org> ;; Author: Milan Zamazal <pdm@zamazal.org>
;; Package-Version: 1 ;; Version: 1
;; Package-Requires: ((emacs "28.1")) ;; Package-Requires: ((emacs "28.1"))
;; Keywords: multimedia ;; Keywords: multimedia
;; URL: https://git.zamazal.org/pdm/pipewire-0 ;; URL: https://git.zamazal.org/pdm/pipewire-0
@ -35,6 +35,8 @@
(require 'cl-lib) (require 'cl-lib)
(require 'pw-access) (require 'pw-access)
;;; Code:
(defvar pw-lib--accessor (pw-cli-accessor)) (defvar pw-lib--accessor (pw-cli-accessor))
(defvar pw-lib--objects '()) (defvar pw-lib--objects '())
@ -118,7 +120,7 @@ A list of strings (possibly empty) is returned."
"Set the profile of the given device. "Set the profile of the given device.
DEVICE-ID is the numeric id of the device. DEVICE-ID is the numeric id of the device.
PROFILE is a string name of the profile, it must be one of the values PROFILE is a string name of the profile, it must be one of the values
returned from `pw-lib-profiles'. " returned from `pw-lib-profiles'."
(let* ((all-profiles (pw-access-profiles pw-lib--accessor device-id)) (let* ((all-profiles (pw-access-profiles pw-lib--accessor device-id))
(properties (cl-find profile all-profiles :key #'pw-lib--profile-name :test #'equal))) (properties (cl-find profile all-profiles :key #'pw-lib--profile-name :test #'equal)))
(unless properties (unless properties
@ -129,9 +131,9 @@ returned from `pw-lib-profiles'. "
(pw-access-set-profile pw-lib--accessor device-id index)))) (pw-access-set-profile pw-lib--accessor device-id index))))
(defun pw-lib-parent-node (object) (defun pw-lib-parent-node (object)
"Return parent node of `object'. "Return parent node of OBJECT.
This is typically used for ports. This is typically used for ports.
Behavior is undefined if `object' has no parent node." Behavior is undefined if OBJECT has no parent node."
(pw-lib-get-object (pw-lib-object-value object "node.id"))) (pw-lib-get-object (pw-lib-object-value object "node.id")))
(defun pw-lib--node (object) (defun pw-lib--node (object)
@ -249,7 +251,7 @@ version, call `pw-lib-refresh' first."
(list node-p parameters monitor-p node-id port-id))) (list node-p parameters monitor-p node-id port-id)))
(defun pw-lib-muted-p (object &optional refresh) (defun pw-lib-muted-p (object &optional refresh)
"Return whether the given PipeWire object is muted. "Return whether the given PipeWire OBJECT is muted.
Applicable only to Nodes and Ports. Applicable only to Nodes and Ports.
If REFRESH is non-nil then retrive fresh information from PipeWire If REFRESH is non-nil then retrive fresh information from PipeWire
rather than using cached data to obtain the result." rather than using cached data to obtain the result."
@ -272,7 +274,7 @@ rather than using cached data to obtain the result."
mute))) mute)))
(defun pw-lib-volume (object &optional refresh) (defun pw-lib-volume (object &optional refresh)
"Return volume of the given PipeWire object. "Return volume of the given PipeWire OBJECT.
The returned value is an integer in the range 0-100. The returned value is an integer in the range 0-100.
Applicable only to Nodes and Ports. Applicable only to Nodes and Ports.
If REFRESH is non-nil then retrive fresh information from PipeWire If REFRESH is non-nil then retrive fresh information from PipeWire
@ -324,7 +326,7 @@ otherwise set the current default sink or source."
("Node" ("Node"
(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)

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2022 Milan Zamazal <pdm@zamazal.org> ;; Copyright (C) 2022 Milan Zamazal <pdm@zamazal.org>
;; Author: Milan Zamazal <pdm@zamazal.org> ;; Author: Milan Zamazal <pdm@zamazal.org>
;; Package-Version: 1 ;; Version: 1
;; Package-Requires: ((emacs "25.1")) ;; Package-Requires: ((emacs "25.1"))
;; Keywords: multimedia ;; Keywords: multimedia
;; URL: https://git.zamazal.org/pdm/pipewire-0 ;; URL: https://git.zamazal.org/pdm/pipewire-0
@ -33,6 +33,8 @@
(require 'pw-lib) (require 'pw-lib)
;;; Code:
(defgroup pipewire () (defgroup pipewire ()
"PipeWire user interface." "PipeWire user interface."
:group 'multimedia) :group 'multimedia)
@ -295,7 +297,9 @@ object. Otherwise apply it on the default audio sink."
VOLUME must be a number in the range 0-100. VOLUME must be a number in the range 0-100.
If OBJECT is given (only Nodes and Ports are allowed) or if on a Node If OBJECT is given (only Nodes and Ports are allowed) or if on a Node
or Port in a PipeWire buffer, apply it on the given object. or Port in a PipeWire buffer, apply it on the given object.
Otherwise apply it on the default audio sink." Otherwise apply it on the default audio sink.
If SINGLE-P is nil, apply it on all related channels, otherwise on the
corresponding object only."
(interactive "nVolume: ") (interactive "nVolume: ")
(setq volume (max 0 (min 100 volume))) (setq volume (max 0 (min 100 volume)))
(unless object (unless object
@ -315,8 +319,8 @@ Otherwise apply it on the default audio sink."
"Increase volume of an audio output or input. "Increase volume of an audio output or input.
The volume is increased by `pipewire-volume-step'. The volume is increased by `pipewire-volume-step'.
If on a Node or Port in a PipeWire buffer, apply it on all the If on a Node or Port in a PipeWire buffer, apply it on all the
channels of the given object. Otherwise apply it on the default audio channels of the given object, unless SINGLE-P is non-nil.
sink." Otherwise apply it on the default audio sink."
(interactive) (interactive)
(pw-ui--change-volume pipewire-volume-step single-p)) (pw-ui--change-volume pipewire-volume-step single-p))
@ -334,8 +338,8 @@ object. Otherwise apply it on the default audio sink."
"Decrease volume of an audio output or input. "Decrease volume of an audio output or input.
The volume is decreased by `pipewire-volume-step'. The volume is decreased by `pipewire-volume-step'.
If on a Node or Port in a PipeWire buffer, apply it on all the If on a Node or Port in a PipeWire buffer, apply it on all the
channels of the given object. Otherwise apply it on the default audio channels of the given object, unless SINGLE-P is non-nil.
sink." Otherwise apply it on the default audio sink."
(interactive) (interactive)
(pw-ui--change-volume (- pipewire-volume-step) single-p)) (pw-ui--change-volume (- pipewire-volume-step) single-p))