Created
September 10, 2020 20:08
-
-
Save tychoish/3ba513f7bda27a8cba35039205b700cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defcommand dump-desktop-office ()() | |
(dump-desktop-to-filename (format nil "~a/layout/~a-office" *conf-dir* (machine-instance))) | |
(dump-window-placement-rules "office")) | |
(defcommand restore-desktop-office ()() | |
(restore-from-filename (format nil "~a/layout/~a-office" *conf-dir* (machine-instance)))) | |
(defcommand dump-desktop-laptop ()() | |
(dump-desktop-to-filename (format nil "~a/layout/~a-laptop" *conf-dir* (machine-instance))) | |
(dump-window-placement-rules "laptop")) | |
(defcommand restore-desktop-laptop ()() | |
(restore-from-filename (format nil "~a/layout/~a-laptop" *conf-dir* (machine-instance)))) | |
(defun restore-from-filename (file) | |
(let ((dump (read-dump-from-file file))) | |
(typecase dump | |
(gdump | |
(restore-group (current-group) dump) | |
(message "Group restored.")) | |
(sdump | |
(restore-screen (current-screen) dump) | |
(message "Screen restored.")) | |
(ddump | |
(restore-desktop dump) | |
(message "Desktop restored.")) | |
(t | |
(message "Don't know how to restore ~a." dump))))) | |
(defun dump-desktop-to-filename (file) | |
(dump-to-filename (dump-desktop) file)) | |
(defun dump-to-filename (foo name) | |
(with-open-file (fp name | |
:direction :output | |
:if-exists :supersede | |
:if-does-not-exist :create) | |
(with-standard-io-syntax | |
(let ((*package* (find-package :stumpwm)) | |
(*print-pretty* t)) | |
(prin1 foo fp))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment