1 ;;; --------------------------------------------------------------------------
2 ;;; CLFSWM - FullScreen Window Manager
4 ;;; --------------------------------------------------------------------------
5 ;;; Documentation: Reboot and halt menu
6 ;;; --------------------------------------------------------------------------
8 ;;; (C) 2011 Philippe Brochard <hocwp@free.fr>
10 ;;; This program is free software; you can redistribute it and/or modify
11 ;;; it under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or
13 ;;; (at your option) any later version.
15 ;;; This program is distributed in the hope that it will be useful,
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with this program; if not, write to the Free Software
22 ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 ;;; Documentation: If you want to use this file, just add this line in
25 ;;; your configuration file:
27 ;;; (load-contrib "mpd.lisp")
29 ;;; --------------------------------------------------------------------------
33 (format t
"Loading Reboot/Halt code... ")
36 (defun reboot-halt-menu ()
37 "Open the Reboot/Halt menu"
38 (open-menu (find-menu 'reboot-halt-menu
)))
41 (defun do-with-terminal (command)
42 (do-shell (format nil
"xterm -e '~A'" command
)))
43 ;;(do-shell (format nil "xterm -e 'echo ~A; sleep 3'" command))) ;; test
50 "Suspend the computer to RAM"
51 (do-with-terminal "sudo pm-suspend"))
53 (defun do-hibernate ()
54 "Suspend the computer to DISK"
55 (do-with-terminal "sudo pm-hibernate"))
59 (do-with-terminal "sudo reboot"))
63 (do-with-terminal "sudo halt"))
65 (unless (find-menu 'reboot-halt-menu
)
66 (add-sub-menu 'clfswm-menu
"Pause" 'reboot-halt-menu
"Suspend/Reboot/Halt menu")
67 (add-menu-key 'reboot-halt-menu
"-" 'do-nothing
)
68 (add-menu-key 'reboot-halt-menu
"s" 'do-suspend
)
69 (add-menu-key 'reboot-halt-menu
"d" 'do-hibernate
)
70 (add-menu-key 'reboot-halt-menu
"r" 'do-reboot
)
71 (add-menu-key 'reboot-halt-menu
"h" 'do-halt
))
74 (defun reboot-halt-binding ()
75 (define-main-key ("Pause") 'reboot-halt-menu
))
77 (add-hook *binding-hook
* 'reboot-halt-binding
)