feat(lib): set-frame-opacity: add FRAMES argument

Doesn't change the default behavior of the command, but adds an optional
FRAMES argument (a list of frames or `t` for all open and future
frames). If passed the prefix arg, FRAMES default to `t`, which applies
the opacity change to all open and future frames.

Close: #8395
Co-authored-by: lattarov <lattarov@users.noreply.github.com>
This commit is contained in:
Henrik Lissner
2025-08-10 14:56:59 +02:00
parent 9b1245708b
commit 2c18b61c99

View File

@@ -176,11 +176,15 @@ Use `winner-undo' to undo this. Alternatively, use
(while (ignore-errors (windmove-down)) (delete-window)))) (while (ignore-errors (windmove-down)) (delete-window))))
;;;###autoload ;;;###autoload
(defun doom/set-frame-opacity (opacity) (defun doom/set-frame-opacity (opacity &optional frames)
"Interactively change the current frame's opacity. "Interactively change the current frame's opacity.
OPACITY is an integer between 0 to 100, inclusive." OPACITY is an integer between 0 to 100, inclusive. FRAMES is a list of frames to
(interactive '(interactive)) apply the change to or `t' (meaning all open and future frames). If called
interactively, FRAMES defaults to the current frame (or `t' with the prefix
arg)."
(interactive
(list 'interactive (if current-prefix-arg t (list (selected-frame)))))
(let* ((parameter (let* ((parameter
(if (eq window-system 'pgtk) (if (eq window-system 'pgtk)
'alpha-background 'alpha-background
@@ -190,8 +194,15 @@ OPACITY is an integer between 0 to 100, inclusive."
(read-number "Opacity (0-100): " (read-number "Opacity (0-100): "
(or (frame-parameter nil parameter) (or (frame-parameter nil parameter)
100)) 100))
opacity))) opacity))
(set-frame-parameter nil parameter opacity))) (alist `((,parameter . ,opacity))))
(if (eq frames t)
(modify-all-frames-parameters alist)
(dolist (frame (if (eq frames t) (frame-list) frames))
(modify-frame-parameters frame alist))
(when frame-notice-user-settings ; only necessary at startup
(setf (alist-get (car alist) initial-frame-alist) (cdr alist)))
(setf (alist-get (car alist) default-frame-alist) (cdr alist)))))
(defvar doom--narrowed-base-buffer nil) (defvar doom--narrowed-base-buffer nil)
;;;###autoload ;;;###autoload