My stumpwm configuration

app-menu.lisp 1.1KB

1234567891011121314151617181920212223242526272829303132
  1. ;;;; app-menu.lisp
  2. (in-package #:app-menu)
  3. ;;; "app-menu" goes here. Hacks and glory await!
  4. (export '(show-menu load-menu-file))
  5. (defvar *app-menu* nil "Where the menu structure is held")
  6. (defun load-menu-file (file-name &key (strip 0))
  7. (with-open-file (file file-name)
  8. (when (char= #\# (peek-char nil file)) (read-line file)) ; Hack around the "autogenerated file" comment
  9. (let* ((*read-eval* nil)
  10. (list (list (read file))))
  11. (dotimes (i strip) (setf list (mapcan #'cdr list)))
  12. (setf *app-menu* (nconc *app-menu* list)))))
  13. (defcommand show-menu () ()
  14. "Show the application menu"
  15. (let ((stack (list *app-menu*)))
  16. (loop
  17. (let ((choice
  18. (cdr (select-from-menu (current-screen)
  19. (append (first stack)
  20. (list (cons "Up a level" :up)))))))
  21. (cond
  22. ((not choice) (return))
  23. ((eq choice :up) (pop stack) (unless stack (return)))
  24. ((stringp choice) (run-shell-command choice) (return))
  25. (t (push choice stack)))))))