1 ;;; --------------------------------------------------------------------------
2 ;;; CLFSWM - FullScreen Window Manager
4 ;;; --------------------------------------------------------------------------
5 ;;; Documentation: Reboot and halt menu
6 ;;; --------------------------------------------------------------------------
8 ;;; (C) 2014 Philippe Brochard <pbrochard@common-lisp.net>
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... ")
35 (defconfig *power-suspend-to-ram-cmd
* "sudo pm-suspend"
36 'power-management
"Suspend to ram command")
37 (defconfig *power-suspend-to-disk-cmd
* "sudo pm-hibernate"
38 'power-management
"Suspend to disk command")
39 (defconfig *power-reboot-cmd
* "sudo /sbin/reboot"
40 'power-management
"Reboot command")
41 (defconfig *power-halt-cmd
* "sudo /sbin/halt"
42 'power-management
"Halt command")
44 (defun reboot-halt-menu ()
45 "Open the Reboot/Halt menu"
46 (open-menu (find-menu 'reboot-halt-menu
)))
49 (defun do-with-terminal (command)
50 (do-shell (format nil
"xterm -e '~A'" command
)))
51 ;;(do-shell (format nil "xterm -e 'echo ~A; sleep 3'" command))) ;; test
58 "Suspend the computer to RAM"
59 (do-with-terminal *power-suspend-to-ram-cmd
*))
61 (defun do-hibernate ()
62 "Suspend the computer to DISK"
63 (do-with-terminal *power-suspend-to-disk-cmd
*))
67 (do-with-terminal *power-reboot-cmd
*))
71 (do-with-terminal *power-halt-cmd
*))
73 (unless (find-menu 'reboot-halt-menu
)
74 (add-sub-menu 'clfswm-menu
"Pause" 'reboot-halt-menu
"Suspend/Reboot/Halt menu")
75 (add-menu-key 'reboot-halt-menu
"-" 'do-nothing
)
76 (add-menu-key 'reboot-halt-menu
"s" 'do-suspend
)
77 (add-menu-key 'reboot-halt-menu
"d" 'do-hibernate
)
78 (add-menu-key 'reboot-halt-menu
"r" 'do-reboot
)
79 (add-menu-key 'reboot-halt-menu
"h" 'do-halt
))
82 (defun reboot-halt-binding ()
83 (define-main-key ("Pause") 'reboot-halt-menu
))
85 (add-hook *binding-hook
* 'reboot-halt-binding
)