Re: [PATCH] exit function
- From: Christopher Roy Bratusek <zanghar freenet de>
- To: sawfish-list gnome org
- Subject: Re: [PATCH] exit function
- Date: Tue, 17 Nov 2009 17:08:53 +0100
O.K. here's the customizeable version.
I re-used the Misc -> Default Applications in SawfishConfig.
By the way (quit) and (restart) are not touched by this, (exit)
is an extra command, so no need to worry about that.
But I guess (exit 'quit) may be thrown away as it's the same
than just plain (quit).
Chris
diff --git a/lisp/sawfish/wm/autoload.jl b/lisp/sawfish/wm/autoload.jl
index 2f1131a..4e93f93 100644
--- a/lisp/sawfish/wm/autoload.jl
+++ b/lisp/sawfish/wm/autoload.jl
@@ -142,6 +142,7 @@
(autoload-command 'cycle-dock-backwards 'sawfish.wm.commands.x-cycle)
(autoload-command 'xterm 'sawfish.wm.commands.user)
(autoload-command 'browser 'sawfish.wm.commands.user)
+(autoload-command 'exit 'sawfish.wm.commands.user)
(autoload-command '3d-hack 'sawfish.wm.ext.3d-hack)
(autoload-command 'rename-window 'sawfish.wm.windows)
(defgroup audio "Sound" :require sawfish.wm.ext.audio-events)
diff --git a/lisp/sawfish/wm/commands/user.jl b/lisp/sawfish/wm/commands/user.jl
index 0caf38a..a9b5946 100644
--- a/lisp/sawfish/wm/commands/user.jl
+++ b/lisp/sawfish/wm/commands/user.jl
@@ -21,7 +21,8 @@
(define-structure sawfish.wm.commands.user
(export xterm
- browser)
+ browser
+ exit)
(open rep
rep.system
@@ -30,7 +31,8 @@
rep.io.files
sawfish.wm.misc
sawfish.wm.custom
- sawfish.wm.commands)
+ sawfish.wm.commands
+ sawfish.wm.windows)
(defgroup apps "Default Applications" :group misc)
@@ -60,6 +62,40 @@
(system (format nil "%s %s >/dev/null 2>&1 </dev/null &"
browser-program website))))
+ (defcustom reboot-command "sudo shutdown -r now"
+ "The command used to reboot the computer."
+ :type string
+ :group (misc apps))
+
+ (defcustom halt-command "sudo shutdown -h now"
+ "The command used to halt the computer."
+ :type string
+ :group (misc apps))
+
+ (defcustom suspend-command "sudo suspend"
+ "The command used to suspend the computer."
+ :type string
+ :group (misc apps))
+
+ (defcustom hibernate-command "sudo hibernate"
+ "The command used to hibernate the computer."
+ :type string
+ :group (misc apps))
+
+ (define (exit action)
+ (unless (equal action quit)
+ (require 'sawfish.wm.ext.window-history)
+ (map-windows delete-window-safely)
+ (window-history-save))
+ (case action
+ ((exit) (quit))
+ ((quit) (quit))
+ ((reboot) (system (format nil "%s &" reboot-command)))
+ ((halt) (system (format nil "%s &" halt-command)))
+ ((suspend) (system (format nil "%s &" suspend-command)))
+ ((hibernate) (system (format nil "%s &" hibernate-command)))))
+
;;###autoload
(define-command 'xterm xterm #:class 'default)
- (define-command 'browser browser #:class 'default))
+ (define-command 'browser browser #:class 'default)
+ (define-command 'exit exit #:class 'default))
diff --git a/lisp/sawfish/wm/defaults.jl b/lisp/sawfish/wm/defaults.jl
index 02531c4..8b41abf 100644
--- a/lisp/sawfish/wm/defaults.jl
+++ b/lisp/sawfish/wm/defaults.jl
@@ -49,9 +49,13 @@
(when menu
(nconc menu `(()
(,(_ "_Reboot System")
- (system "sudo shutdown -r now &"))
+ (exit 'reboot))
(,(_ "_Shutdown System")
- (system "sudo shutdown -h now &")))))))))
+ (exit 'halt))
+ (,(_ "S_uspend System")
+ (exit 'suspend))
+ (,(_ "_Hibernate System")
+ (exit 'hibernate)))))))))
;; save errors to aid debugging
(require 'sawfish.wm.ext.error-handler)
diff --git a/lisp/sawfish/wm/menus.jl b/lisp/sawfish/wm/menus.jl
index 1d5f63c..3cfdd91 100644
--- a/lisp/sawfish/wm/menus.jl
+++ b/lisp/sawfish/wm/menus.jl
@@ -153,7 +153,8 @@ before killing it.")
(,(_ "Reload Appsmenu") update-apps-menu)
()
(,(_ "Restart Sawfish") restart)
- (,(_ "Quit Sawfish") quit))
+ (,(_ "Quit Sawfish") quit)
+ (,(_ "Exit Sawfish Session") (exit 'exit)))
()
(,(_ "_Help")
(,(_ "_FAQ...") help:show-faq)
diff --git a/man/sawfish.texi b/man/sawfish.texi
index b348407..987cd0b 100644
--- a/man/sawfish.texi
+++ b/man/sawfish.texi
@@ -5514,6 +5514,26 @@ Calls the function of the same name. @code{destroy-window} and
@code{kill-client} both take @code{%W} as argument.
@end defun
+ defun exit @var{action}
+A wrapper around @code{quit}.
+
+First of all, if @var{action} is not @code{quit}, then:
+
+execute @code{delete-window-safely},
+and then @code{window-history-save}.
+
+Then, after that, the following @var{action} calls the following command:
+
+ var{exit} @code{quit}
+ var{quit} @code{quit}
+ var{reboot} @code{reboot-command}
+ var{halt} @code{halt-command}
+ var{suspend} @code{suspend-command}
+ var{hibernate}@code{hibernate-command}
+
+Should not be used, if a session-manager is running.
+ end defun
+
@node Keymaps, Event Loop, Commands, Top
@chapter Keymaps
@cindex Keymaps
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]