[sawfish] added sawfish.wm.integration and sawfish.wm.commands.poweroff tandem
- From: Christopher Bratusek <chrisb src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [sawfish] added sawfish.wm.integration and sawfish.wm.commands.poweroff tandem
- Date: Sat, 5 Dec 2009 11:02:52 +0000 (UTC)
commit a9413bd714d5f671481707d4ef051d5c9a95ae2e
Author: Christopher Roy Bratusek <chris nanolx org>
Date: Sat Dec 5 12:01:40 2009 +0100
added sawfish.wm.integration and sawfish.wm.commands.poweroff tandem
ChangeLog | 17 +++++++
OPTIONS | 14 ++++++
lisp/sawfish/wm/autoload.jl | 1 +
lisp/sawfish/wm/commands/poweroff.jl | 72 +++++++++++++++++++++++++++++
lisp/sawfish/wm/defaults.jl | 15 +------
lisp/sawfish/wm/integration/gnome.jl | 2 +
lisp/sawfish/wm/integration/kde.jl | 2 +
lisp/sawfish/wm/integration/standalone.jl | 47 +++++++++++++++++++
lisp/sawfish/wm/user.jl | 7 ++-
man/news.texi | 19 ++++++--
man/sawfish.texi | 17 +++++++
11 files changed, 194 insertions(+), 19 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e91faba..f58b7b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,23 @@
* lisp/sawfish/wm/commands/launcher.jl: addded structure alias
+ * OPTIONS
+ * lisp/sawfish/wm/autoload.jl
+ * lisp/sawfish/wm/defaults.jl
+ * lisp/sawfish/wm/commands/poweroff.jl
+ * lisp/sawfish/wm/integration/gnome.jl
+ * lisp/sawfish/wm/integration/kde.jl
+ * lisp/sawfish/wm/integration/standalone.jl
+ * lisp/sawfish/wm/user.jl
+ * man/sawfish.texi: Added poweroff command for letting none KDE/GNOME users easily
+ reboot, halt, suspend or hibernate their machine. The commands
+ beeing used to do so are also user-settable. In addition when
+ it's used to reboot or halt, when the call the `before-exit-hook'
+ and `map-windows delete-window' before actually rebooting or,
+ to ensure everything is fine on the next startup. Furthermore
+ entries to the session-menu are beeing added. If you're using
+ KDE or GNOME then those are not generated.
+
2009-12-05 Teika Kazura <teika lavabit com>
* lisp/sawfish/wm/custom-defaults.jl
* lisp/sawfish/wm/ext/match-window.jl
diff --git a/OPTIONS b/OPTIONS
index 21e816b..acfe930 100644
--- a/OPTIONS
+++ b/OPTIONS
@@ -663,3 +663,17 @@
;; (define-special-variable infinite-desktop.move-cursor-distance 32
;; "Amount to move the cursor after moving the workspace.")
+
+;; poweroff options
+
+;; (define-special-variable reboot-command "sudo shutdown -r now"
+;; "The command used to reboot the computer.")
+
+;; (define-special-variable halt-command "sudo shutdown -h now"
+;; "The command used to halt the computer.")
+
+;; (define-special-variable suspend-command "sudo suspend"
+;; "The command used to suspend the computer.")
+
+;; (define-special-variable hibernate-command "sudo hibernate"
+;; "The command used to hibernate the computer.")
diff --git a/lisp/sawfish/wm/autoload.jl b/lisp/sawfish/wm/autoload.jl
index 9482abd..58d3f3e 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 'poweroff 'sawfish.wm.commands.poweroff)
(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/poweroff.jl b/lisp/sawfish/wm/commands/poweroff.jl
new file mode 100644
index 0000000..e51f4ee
--- /dev/null
+++ b/lisp/sawfish/wm/commands/poweroff.jl
@@ -0,0 +1,72 @@
+;; poweroff.jl -- reboot, halt, suspend or hibernate your machine
+;;
+;; Copyright (C) 2009 Christopher Roy Bratusek <zanghar freenet de>
+;;
+;; 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.commands.poweroff
+
+ (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 poweroff sawfish.wm.commands.poweroff)
+
+ (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 (poweroff action)
+ (case action
+ ((reboot)
+ (call-hook 'before-exit-hook)
+ (map-windows delete-window)
+ (system (format nil "%s &" reboot-command)))
+ ((halt)
+ (call-hook 'before-exit-hook)
+ (map-windows delete-window)
+ (system (format nil "%s &" halt-command)))
+ ((suspend) (system (format nil "%s &" suspend-command)))
+ ((hibernate) (system (format nil "%s &" hibernate-command)))))
+
+ ;;###autoload
+ (define-command 'poweroff poweroff #:class 'default))
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/gnome.jl b/lisp/sawfish/wm/integration/gnome.jl
index 74a5701..37011a3 100644
--- a/lisp/sawfish/wm/integration/gnome.jl
+++ b/lisp/sawfish/wm/integration/gnome.jl
@@ -30,6 +30,8 @@
(define-structure-alias gnome-int sawfish.wm.integration.gnome)
+ (define-special-variable extra-session-menu nil)
+
;; invoke the GNOME terminal instead of xterm
(unless (variable-customized-p 'xterm-program)
(setq xterm-program "gnome-terminal.wrapper"))
diff --git a/lisp/sawfish/wm/integration/kde.jl b/lisp/sawfish/wm/integration/kde.jl
index 661d7dc..57e616c 100644
--- a/lisp/sawfish/wm/integration/kde.jl
+++ b/lisp/sawfish/wm/integration/kde.jl
@@ -30,6 +30,8 @@
(define-structure-alias kde-int sawfish.wm.integration.kde)
+ (define-special-variable extra-session-menu nil)
+
;; invoke the KDE terminal instead of xterm
(unless (variable-customized-p 'xterm-program)
(setq xterm-program "konsole"))
diff --git a/lisp/sawfish/wm/integration/standalone.jl b/lisp/sawfish/wm/integration/standalone.jl
new file mode 100644
index 0000000..69dd103
--- /dev/null
+++ b/lisp/sawfish/wm/integration/standalone.jl
@@ -0,0 +1,47 @@
+;; 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 `(()
+ (,(_ "_Reboot System")
+ (poweroff 'reboot))
+ (,(_ "_Shutdown System")
+ (poweroff 'halt))
+ (,(_ "S_uspend System")
+ (poweroff 'suspend))
+ (,(_ "_Hibernate System")
+ (poweroff 'hibernate)))))))))
diff --git a/lisp/sawfish/wm/user.jl b/lisp/sawfish/wm/user.jl
index 07dda68..ca232e4 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.poweroff)
(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/news.texi b/man/news.texi
index 67ebd27..f4b3b33 100644
--- a/man/news.texi
+++ b/man/news.texi
@@ -116,6 +116,17 @@ defined in the module cited above. Variable @code{display-url-command} is
renamed to @code{browser-program}.
@end itemize
+ item Poweroff actions
+
+Added poweroff command for letting none KDE/GNOME users easily
+reboot, halt, suspend or hibernate their machine. The commands
+beeing used to do so are also user-settable. In addition when
+it's used to reboot or halt, when the call the `before-exit-hook'
+and `map-windows delete-window' before actually rebooting or,
+to ensure everything is fine on the next startup. Furthermore
+entries to the session-menu are beeing added. If you're using
+KDE or GNOME then those are not generated.
+
@item Bugs fixed:
@itemize @minus
@@ -153,7 +164,7 @@ Kozicki]
@item Expand REP_ENVIRON in scripts/Makefile.in [Luis Rodrigo Gallardo Cruz]
- item Add @code{--tag=CC} to libtool where necessary. It unbrakes compilation on some arches [Gentoo Linux]
+ item Add @code{--tag=CC} to libtool where necessary. It unbrakes compilation on some arches [Gentoo Linux]
@end itemize
@item In configurator,
@@ -207,7 +218,7 @@ Internally, a new function @code{remove-frame-part-value} which allows to change
@item Xinerama support for Grow/Pack [Nolan Leake]
Make grow/pack Xinerama aware. The support still remains basic.
-Shrink-yank doesn't yet.
+Shrink-yank doesn't yet.
@item Window rules can be set by lisp
@@ -234,7 +245,7 @@ Sawfish can ``translate'' keymaps for each window. Suppose you have
the following lines in your @file{~/.sawfish/rc}:
@lisp
-(add-window-matcher
+(add-window-matcher
'((WM_NAME . "^Terminal$"))
'(keymap-trans . (("C-n" "C-S-t")
("C-w" "C-S-w"))))
@@ -325,7 +336,7 @@ changes.
@item Startup window placement improvement [Jeremy Hankins]
-At Sawfish startup including restart, maximized windows and
+At Sawfish startup including restart, maximized windows and
position specified windows used to mess up viewport, appearing
in wrong viewports. It is fixed.
diff --git a/man/sawfish.texi b/man/sawfish.texi
index 9475008..3bcae36 100644
--- a/man/sawfish.texi
+++ b/man/sawfish.texi
@@ -5575,6 +5575,23 @@ Calls the function of the same name. @code{destroy-window} and
@code{kill-client} both take @code{%W} as argument.
@end defun
+ defun poweroff @var{action}
+A function for rebooting, halting, suspending and hibernating
+your machine. Normally this is only used when running outside
+of GNOME or KDE, as their functions for doing so are beeing used then.
+
+The following @var{action} calls the following command:
+
+ var{reboot} @code{reboot-command}
+ var{halt} @code{halt-command}
+ var{suspend} @code{suspend-command}
+ var{hibernate} @code{hibernate-command}
+
+Plus when @var{action} is @var{reboot} or @var{halt}, the
+ code{before-exit-hook} and afterwards @code{map-windows delete-windows},
+to ensure we safely quit the current session.
+ 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]