Better name for end-session command variable, added configuration example to README

This commit is contained in:
Alexander van den Berghe 2023-02-16 13:56:34 +01:00
parent ce05cce7ca
commit 0372363161
3 changed files with 7 additions and 5 deletions

View file

@ -12,6 +12,8 @@
(add-to-load-path #p"path-to-contrib/util/end-session")
;; actually load the module
(load-module "end-session")
;; Use loginctl instead of the default systemctl
(setf end-session:*end-session-command* "loginctl")
#+END_SRC
*** Commands Provided:
- =end-session= Prompts for shutdown, restart, or logoff. You can

View file

@ -28,7 +28,7 @@
;;; DEALINGS IN THE SOFTWARE.
;;;
(defvar *base-command* "systemctl")
(defvar *end-session-command* "systemctl")
(defun yes-no-diag (query-string)
"Presents a yes-no dialog to the user asking query-string.
@ -43,7 +43,7 @@ Returns true when yes is selected"
(let ((choice (yes-no-diag "Really suspend?")))
(when choice
(echo-string (current-screen) "Suspending...")
(run-shell-command (concat *base-command* " suspend")))))
(run-shell-command (concat *end-session-command* " suspend")))))
(defun close-all-apps ()
"Closes all windows managed by stumpwm gracefully"
@ -58,7 +58,7 @@ Returns true when yes is selected"
(echo-string (current-screen) "Shutting down...")
(close-all-apps)
(run-hook *quit-hook*)
(run-shell-command (concat *base-command* " poweroff")))))
(run-shell-command (concat *end-session-command* " poweroff")))))
;; can't name the function "restart"
(defcommand restart-computer () ()
@ -67,7 +67,7 @@ Returns true when yes is selected"
(echo-string (current-screen) "Restarting...")
(close-all-apps)
(run-hook *quit-hook*)
(run-shell-command (concat *base-command* " reboot")))))
(run-shell-command (concat *end-session-command* " reboot")))))
(defcommand logout () ()
(let ((choice (yes-no-diag "Close all programs and quit stumpwm?")))

View file

@ -2,4 +2,4 @@
(defpackage #:end-session
(:use #:cl :stumpwm)
(:export #:*base-command*))
(:export #:*end-session-command*))