Re: [PATCH] exit function
- From: Christopher Roy Bratusek <zanghar freenet de>
- To: sawfish-list gnome org
- Subject: Re: [PATCH] exit function
- Date: Tue, 24 Nov 2009 18:34:06 +0100
ahh, another small update:
* updated doc
* some indention fixes
* add structure-alias to sawfish.wm.commands.exit
Chris
diff --git a/lisp/sawfish/wm/autoload.jl b/lisp/sawfish/wm/autoload.jl
index 9482abd..b633ca3 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.launcher)
(autoload-command 'browser 'sawfish.wm.commands.launcher)
+(autoload-command 'exit 'sawfish.wm.commands.exit)
(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/exit.jl b/lisp/sawfish/wm/commands/exit.jl
new file mode 100644
index 0000000..8b7965e
--- /dev/null
+++ b/lisp/sawfish/wm/commands/exit.jl
@@ -0,0 +1,72 @@
+;; exit.jl -- command to launch external apps, xterm & browser
+;;
+;; Copyright (C) 2000 John Harper <john dcs warwick ac uk>
+;;
+;; This file is part of sawfish.
+;;
+;; sawfish is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+;;
+;; sawfish is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with sawfish; see the file COPYING. If not, write to
+;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+;; This module was renamed from xterm in Sawfish-1.6.
+(define-structure sawfish.wm.commands.exit
+
+ (export exit)
+
+ (open rep
+ rep.system
+ rep.regexp
+ rep.io.timers
+ rep.io.files
+ sawfish.wm.misc
+ sawfish.wm.custom
+ sawfish.wm.commands
+ sawfish.wm.commands.launcher
+ sawfish.wm.windows)
+
+ (define-structure-alias exit sawfish.wm.commands.exit)
+
+ (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)
+ (require 'sawfish.wm.ext.window-history)
+ (window-history-save)
+ (map-windows delete-window)
+ (call-hook 'before-exit-hook)
+ (case action
+ ((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 'exit exit #:class 'default))
diff --git a/lisp/sawfish/wm/commands/launcher.jl b/lisp/sawfish/wm/commands/launcher.jl
index 83c7d8e..70408fb 100644
--- a/lisp/sawfish/wm/commands/launcher.jl
+++ b/lisp/sawfish/wm/commands/launcher.jl
@@ -33,6 +33,8 @@
sawfish.wm.custom
sawfish.wm.commands)
+ (define-structure-alias launcher sawfish.wm.commands.launcher)
+
(defgroup apps "External Applications" :group misc)
(defcustom xterm-program "xterm"
diff --git a/lisp/sawfish/wm/defaults.jl b/lisp/sawfish/wm/defaults.jl
index 02531c4..1fe78b7 100644
--- a/lisp/sawfish/wm/defaults.jl
+++ b/lisp/sawfish/wm/defaults.jl
@@ -38,20 +38,7 @@
;; if it looks like KDE is the desktop environment, then load the
;; extra KDE integration module
(if (getenv "KDE_SESSION_VERSION")
- (require 'sawfish.wm.integration.kde)
-
-;; if neither GNOME nor KDE is running, append standard
-;; reboot and shutdown actions to the session submenu
-
-;; read README.IMPORTANT if you don't know how to make
-;; non-root users able to use `shutdown'
- (let ((menu (assoc (_ "Sessi_on") root-menu)))
- (when menu
- (nconc menu `(()
- (,(_ "_Reboot System")
- (system "sudo shutdown -r now &"))
- (,(_ "_Shutdown System")
- (system "sudo shutdown -h now &")))))))))
+ (require 'sawfish.wm.integration.kde))))
;; save errors to aid debugging
(require 'sawfish.wm.ext.error-handler)
diff --git a/lisp/sawfish/wm/integration/standalone.jl b/lisp/sawfish/wm/integration/standalone.jl
new file mode 100644
index 0000000..09033e3
--- /dev/null
+++ b/lisp/sawfish/wm/integration/standalone.jl
@@ -0,0 +1,49 @@
+;; standalone.jl
+
+;; Copyright (C) 2000 John Harper <john dcs warwick ac uk>
+
+;; This file is part of sawfish.
+
+;; sawfish is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; sawfish is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with sawfish; see the file COPYING. If not, write to
+;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+(define-structure sawfish.wm.integration.standalone
+
+ (export add-extra-session-menu)
+
+ (open rep
+ rep.system
+ sawfish.wm.menus
+ sawfish.wm.custom
+ sawfish.wm.commands)
+
+ (define-structure-alias standalone-int sawfish.wm.integration.standalone)
+
+ (defvar extra-session-menu t)
+
+ (define (add-extra-session-menu)
+ (if extra-session-menu
+ (let ((menu (assoc (_ "Sessi_on") root-menu)))
+ (when menu
+ (nconc menu `((,(_ "_Exit Sawfish Session")
+ (exit 'quit))
+ ()
+ (,(_ "_Reboot System")
+ (exit 'reboot))
+ (,(_ "_Shutdown System")
+ (exit 'halt))
+ (,(_ "S_uspend System")
+ (exit 'suspend))
+ (,(_ "_Hibernate System")
+ (exit 'hibernate)))))))))
diff --git a/lisp/sawfish/wm/user.jl b/lisp/sawfish/wm/user.jl
index 07dda68..6db2dce 100644
--- a/lisp/sawfish/wm/user.jl
+++ b/lisp/sawfish/wm/user.jl
@@ -47,7 +47,9 @@
sawfish.wm.util.compat
sawfish.wm.ext.error-handler
sawfish.wm.ext.apps-menu
- sawfish.wm.frames)
+ sawfish.wm.frames
+ sawfish.wm.integration.standalone
+ sawfish.wm.commands.exit)
(set-binds))
(setq *user-structure* 'user)
@@ -122,6 +124,9 @@
(if use-custom-font-color
(update-frame-font-color))
+ (if extra-session-menu
+ (add-extra-session-menu))
+
;; use a default theme if none given
(unless (or batch-mode default-frame-style)
(setq default-frame-style fallback-frame-style))
diff --git a/man/sawfish.texi b/man/sawfish.texi
index cfe831d..db0dddb 100644
--- a/man/sawfish.texi
+++ b/man/sawfish.texi
@@ -2509,7 +2509,7 @@ screen.
@deffnx Command maximize-window-fullscreen window
Maximize both dimensions of @var{window} on the screen, removing
window decorations and making the window edges flush with the screen
-sides.
+sides.
If @var{state} nil, it unmaximizes. Else, it maximizes. If called as
a command, it always maximizes.
@@ -4021,7 +4021,7 @@ for most cases.
The number of viewports of the virtual desktop. This is a cons cell
@code{(columns . rows)}. Defaults to @code{(1 . 1)}.
-If @code{viewport-boundary-mode} is @code{dynamic} (@pxref{Dynamic
+If @code{viewport-boundary-mode} is @code{dynamic} (@pxref{Dynamic
Viewport}), then this variable is the current size of the current
workspace, and does not have the meaning as a user option.
@end defvar
@@ -4122,7 +4122,7 @@ each step in the motion.
@defvr Customizable scroll-viewport-steps
When you move the viewport, the bigger this value, the more
smoothly the screen is scrolled. It is the number of steps for
-scrolling.
+scrolling.
The default value 1 means the change is instantaneous, and no scroll
is done. The upper limit for customization is 50.
@@ -4150,7 +4150,7 @@ specification may change.
@defvar viewport-minimum-dimensions
This is only useful if dynamic viewport is enabled. It means that
- code{viewport-dimensions} gets never less than this variable.
+ code{viewport-dimensions} gets never less than this variable.
If setting @code{viewport-minimum-dimensions} by hand (not by the
customization interface) be sure to call
@@ -4968,7 +4968,7 @@ Sawfish generates applications menu from @file{*.desktop} files.
If non-nil, @code{apps-menu} is automatically generated from
@code{user-apps-menu} and @file{*.desktop} files. If you set
@code{apps-menu}, then it won't happen anyway.
-
+
Default is @code{t}.
@end defvar
@@ -5544,6 +5544,24 @@ 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 it calls @code{window-history-save}
+then it calls @code{delete-window-safely},
+and then it calls the @code{before-exit} hook.
+
+After that, the following @var{action} calls the following command:
+
+ var{quit} @code{quit}
+ var{reboot} @code{reboot-command}
+ var{halt} @code{halt-command}
+ var{suspend} @code{suspend-command}
+ var{hibernate} @code{hibernate-command}
+
+This should not be used, if a session-manager is running.
+ end defun
+
@node Keymaps, Event Loop, Commands, Top
@chapter Keymaps
@cindex Keymaps
@@ -6446,7 +6464,7 @@ The hook functions are passed one argument which is the command name.
@defvr {Hook} pre-command-hook
Called before each command is evaluated. If you set the value
- code{this-command} to @code{nil} in this hook, then the command
+ code{this-command} to @code{nil} in this hook, then the command
won't be executed.
@end defvr
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]