Skip to content

Instantly share code, notes, and snippets.

@tychoish
Created September 10, 2020 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tychoish/3ba513f7bda27a8cba35039205b700cf to your computer and use it in GitHub Desktop.
Save tychoish/3ba513f7bda27a8cba35039205b700cf to your computer and use it in GitHub Desktop.
(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