Re: [PATCH] exit function
- From: Christopher Roy Bratusek <zanghar freenet de>
- To: sawfish-list gnome org
- Subject: Re: [PATCH] exit function
- Date: Mon, 16 Nov 2009 18:46:51 +0100
Am Mon, 16 Nov 2009 08:15:21 +0100
schrieb Janek Kozicki <janek_listy wp pl>:
> Christopher Roy Bratusek said: (by the date of Sun, 15 Nov 2009
> 19:55:49 +0100)
>
> > (,(_ "Restart Sawfish") restart)
> > - (,(_ "Quit Sawfish") quit))
> > + (,(_ "Quit Sawfish") (exit 'exit)))
>
> Umm... hold on. When I was debugging sawfish with valgrind I often
> had to 'quit' sawfish, in order to start it from another terminal
> (with valgrind). Restarting sawfish wouldn't work for me.
>
> I would never expect "quit sawfish" to close all windows (and reboot
> computer?).
No Reboot, as you can see from the case switch.
> I expect it only to quit, and leave my session as is
> (with all windows left opened, just unmanaged). Then in unamanged
> terminal I was starting 'valgrind sawfish'.
>
> I would prefer if you added four more entries in this submenu:
>
> "Log out session" -> (exit 'exit)
> # this one closes all windows, and stops sawfish
>
> "Halt computer" -> sudo /sbin/halt
> "Reboot computer" -> sudo /sbin/reboot
> "Hibernate computer" -> sudo /usr/sbin/s2disk
>
> And "Quit sawfish"/"Restart sawfish" would just stop sawfish, without
> touching any other processes.
>
> While other commands would perform as expected. With the ability to
> edit in SawfishConfig GUI the shell command to call upon each of them.
> For instance I expect that on some computers "Hibernate computer"
> would need to call something else than standard `/usr/sbin/s2disk`
> (or sometimes `sudo /usr/sbin/hibernate`), on mine it
> is /root/bin/SLEEP
Therefore it's not beeing added, as there are much more possiblities
for suspend. Add the entry manually to the menu, if you need it.
Chris
Improved patch:
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..e491e79 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,16 @@
(system (format nil "%s %s >/dev/null 2>&1 </dev/null &"
browser-program website))))
+ (define (exit action)
+ (require 'sawfish.wm.ext.window-history)
+ (map-windows delete-window-safely)
+ (window-history-save)
+ (case action
+ ((exit) (quit))
+ ((reboot) (system "sudo shutdown -r now &"))
+ ((halt) (system "sudo shutdown -h now &"))))
+
;;###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..d1e8a7a 100644
--- a/lisp/sawfish/wm/defaults.jl
+++ b/lisp/sawfish/wm/defaults.jl
@@ -49,9 +49,9 @@
(when menu
(nconc menu `(()
(,(_ "_Reboot System")
- (system "sudo shutdown -r now &"))
+ (exit 'reboot))
(,(_ "_Shutdown System")
- (system "sudo shutdown -h now &")))))))))
+ (exit 'halt)))))))))
;; 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..63e5797 100644
--- a/man/sawfish.texi
+++ b/man/sawfish.texi
@@ -5514,6 +5514,16 @@ 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}. @code{exit} first @code{delete-window-safely}
+all managed windows, then @code{window-history-save}, to ensure a clean
+window-history on the next start. In addition, if @var{action} is @code{exit},
+then @code{quit} is called directly afterwards, if it's @code{reboot}, then
+the system goes @code{init 6}, if it's halt, then the system goes @code{init 0}.
+
+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]