Boot fixes, scratch windows

This commit is contained in:
Ian Keane 2026-08-09 14:31:49 -04:00
parent 8aa1f8a8a6
commit d3de780583
9 changed files with 740 additions and 0 deletions

View file

@ -54,6 +54,12 @@
(:float t t :class "alsamixer-scratch")
(:float t t :class "ncmpcpp-scratch"))
(define-frame-preference "scratch-emacs-1"
(0 t t :title "scratch-emacs-1"))
(define-frame-preference "scratch-emacs-2"
(0 t t :title "scratch-emacs-2"))
(define-frame-preference "Emacs"
(1 t t :restore "emacs-editing-dump" :title "...xdvi")
(0 t t :create "emacs-dump" :class "Emacs"))
@ -326,3 +332,60 @@ If PERSISTENT is t, smart-kill will hide the window instead of killing it."
(define-key *top-map* (kbd "s-2") "gselect 2")
(define-key *top-map* (kbd "s-3") "gselect 3")
(define-key *top-map* (kbd "s-4") "gselect 4")
;;; Fullscreen scratchpad groups
;;
;; Each scratchpad lives in its own hidden group. Pressing the binding
;; switches to it (spawning the window on first visit). Pressing again
;; returns to wherever you came from. We track the previous group ourselves
;; rather than relying on gother, which is unreliable when windows spawn async.
(defun toggle-scratchpad-group (group-name command &key window-title)
(let* ((screen (current-screen))
(current (current-group))
(target (find-group screen group-name))
(existing (when window-title
(find-if (lambda (w) (string= (window-name w) window-title))
(screen-windows screen)))))
(if (eq current target)
(when *scratchpad-previous-group*
(switch-to-group *scratchpad-previous-group*))
(progn
(setf *scratchpad-previous-group* current)
(when (and existing (not (eq (window-group existing) target)))
(move-window-to-group existing target))
(switch-to-group target)
(unless existing
(run-shell-command command))))))
(run-commands "gnewbg scratch-term-1"
"gnewbg scratch-term-2"
"gnewbg scratch-emacs-1"
"gnewbg scratch-emacs-2")
(defcommand scratch-term-1 () ()
"Toggle fullscreen persistent terminal (wezterm)."
(toggle-scratchpad-group "scratch-term-1"
"wezterm start --class scratch-term-1"))
(defcommand scratch-term-2 () ()
"Toggle second fullscreen persistent terminal (wezterm)."
(toggle-scratchpad-group "scratch-term-2"
"wezterm start --class scratch-term-2"))
(defcommand scratch-emacs-1 () ()
"Toggle fullscreen persistent emacsclient frame."
(toggle-scratchpad-group "scratch-emacs-1"
"emacsclient -c --frame-parameters '((name . \"scratch-emacs-1\"))'"
:window-title "scratch-emacs-1"))
(defcommand scratch-emacs-2 () ()
"Toggle second fullscreen persistent emacsclient frame (leetcode)."
(toggle-scratchpad-group "scratch-emacs-2"
"emacsclient -c --frame-parameters '((name . \"scratch-emacs-2\"))'"
:window-title "scratch-emacs-2"))
(define-key *top-map* (kbd "C-Return") "scratch-term-1")
(define-key *top-map* (kbd "C-\\") "scratch-term-2")
(define-key *top-map* (kbd "s-e") "scratch-emacs-1")
(define-key *top-map* (kbd "s-L") "scratch-emacs-2")