This is pretty nice: "Multi-Monitor Compatible Code to Center Emacs Frames on Screen • Christian Tietze" https://christiantietze.de/posts/2021/06/emacs-center-window/
I made it into a single function:
;; Adapted from: https://christiantietze.de/posts/2021/06/emacs-center-window-on-current-monitor/
(defun gk-frame-recenter (&optional frame)
"Center a frame on the screen."
(unless (eq 'maximised (frame-parameter nil 'fullscreen))
(let* ((w (frame-pixel-width frame))
(h (frame-pixel-height frame))
(cw (caddr (frame-monitor-workarea frame)))
(ch (cadddr (frame-monitor-workarea frame)))
(center (list (/ (- cw w) 2) (/ (- ch h) 2))))
(apply 'set-frame-position (flatten-list (list frame center))))))
(add-hook 'after-init-hook #'gk-frame-recenter)
(add-hook 'after-make-frame-functions #'gk-frame-recenter)
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!