;;; STUMPWM Layout Freezer ;; Author: Christopher Allan Webber ;; STUMPWM Layout Freezer is free software: you can redistribute it ;; and/or modify it under the terms of the GNU General Public License ;; as published by the Free Software Foundation, either version 3 of ;; the License, or (at your option) any later version. ;; This software is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this software. If not, see . ;; -------- ;; Basically this lets you either load a layout from disk or "freeze" ;; the current configuration of that layout (allows your WM to ;; remember where to put the windows when you set it back) ;; I doubt anyone is going to use this, but if you do just ;; dump-group-to-file several layouts and change ;; *layout-freezer-layout-keys* to map with keybindings you think are ;; nice. ;; Hit combinations like " l b" to switch to browsemacs layout ;; (loaded from disk if no frozen version or loaded from memory if ;; frozen) or " l F b" to freeze browsemacs with window ;; configurations into memory. (in-package :stumpwm) (defvar *layout-freezer-layout-keys* '(("b" . "/home/cwebber/.config/stumpwm/browsemacs") ("B" . "/home/cwebber/.config/stumpwm/emacs-browserfull") ("e" . "/home/cwebber/.config/stumpwm/emacs2") ("E" . "/home/cwebber/.config/stumpwm/emacschat"))) (defvar *layout-freezer-layout-freezer* nil) (defvar *layout-freezer-layout-keymap* (make-sparse-keymap)) (defvar *layout-freezer-layout-freezer-keymap* (make-sparse-keymap)) (defun layout-freezer-setup-layout () "Sets up both the layout and the freezer sub-layout." (setf *layout-freezer-layout-keymap* (make-sparse-keymap)) (setf *layout-freezer-layout-freezer-keymap* (make-sparse-keymap)) (dolist (key-and-file *layout-freezer-layout-keys*) (let ((key (car key-and-file))) ; Set up the general binding (define-key *layout-freezer-layout-keymap* (kbd key) (concat "load-custom-layout " key)) (define-key *layout-freezer-layout-freezer-keymap* (kbd key) (concat "freeze-custom-layout " key)))) ; Bind these (define-key *layout-freezer-layout-keymap* (kbd "F") '*layout-freezer-layout-freezer-keymap*) (define-key *root-map* (kbd "l") '*layout-freezer-layout-keymap*)) (layout-freezer-setup-layout) (defcommand freeze-custom-layout (key) ((:rest "blah: ")) "Freeze this custom layout" (setf *layout-freezer-layout-freezer* (acons key (dump-group (current-group)) *layout-freezer-layout-freezer*))) (defcommand load-custom-layout (key) ((:rest "blah: ")) "Load a custom layout associated with this key, possibly a frozen one if set" (let* ((frozen-layout (cdr (assoc key *layout-freezer-layout-freezer* :test 'equal)))) (restore-group (current-group) ; Restore from the frozen layout, or get the layout from the file (or frozen-layout (read-dump-from-file (cdr (assoc key *layout-freezer-layout-keys* :test 'equal)))))))