When quitting StumpWM using the command `quit', the variable `*confirm-kill-stumpwm*' can hold a predicate which evaluates to t to quit StumpWM.
The function `windows-query-on-exit' is a predicate that evaluates to t if no window exist or the user answers "yes" to the query. `*confirm-kill-stumpwm*' can hold any predicate but `windows-query-on-exit' is provided so the user do not accidentally quit StumpWM while windows exist. `*confirm-kill-stumpwm*' is nil by default so there is no change on the current behavior. --- user.lisp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/user.lisp b/user.lisp index 5f358de..04e4030 100644 --- a/user.lisp +++ b/user.lisp @@ -31,7 +31,10 @@ run-or-raise run-or-pull run-shell-command - window-send-string)) + window-send-string + *confirm-kill-stumpwm* + windows-query-on-exit + )) (defun restarts-menu (err) "Display a menu with the active restarts and let the user pick @@ -222,10 +225,24 @@ such a case, kill the shell command to resume StumpWM." (defcommand-alias abort keyboard-quit) +(defun windows-query-on-exit () + "t if no window exist or the user wants to exit anyway." + (or (null (all-windows)) + (yes-or-no-p "Active windows exist; kill them and exit anyway? "))) + +(defvar *confirm-kill-stumpwm* nil + "If non-nil, predicate function to confirm killing StumpWM. + +Nil means to not ask.") (defcommand quit () () -"Quit StumpWM." - (throw :top-level :quit)) + "Quit StumpWM. + +Use the variable `*confirm-kill-stumpwm*' to hold a predicate. This +predicate evaluates to t when you want to quit." + (when (or (null *confirm-kill-stumpwm*) + (funcall *confirm-kill-stumpwm*)) + (throw :top-level :quit))) (defcommand restart-soft () () "Soft Restart StumpWM. The lisp process isn't restarted. Instead, -- 1.7.10.4 _______________________________________________ Stumpwm-devel mailing list Stumpwm-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/stumpwm-devel