Switch to asdf2 in contrib directory
[clfswm.git] / contrib / reboot-halt.lisp
blobcddbde003747de6123542525c070b44cc9670f0d
1 ;;; --------------------------------------------------------------------------
2 ;;; CLFSWM - FullScreen Window Manager
3 ;;;
4 ;;; --------------------------------------------------------------------------
5 ;;; Documentation: Reboot and halt menu
6 ;;; --------------------------------------------------------------------------
7 ;;;
8 ;;; (C) 2011 Philippe Brochard <hocwp@free.fr>
9 ;;;
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.
14 ;;;
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.
19 ;;;
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.
23 ;;;
24 ;;; Documentation: If you want to use this file, just add this line in
25 ;;; your configuration file:
26 ;;;
27 ;;; (load-contrib "mpd.lisp")
28 ;;;
29 ;;; --------------------------------------------------------------------------
31 (in-package :clfswm)
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
45 (defun do-nothing ()
46 "Do nothing"
47 ())
49 (defun do-suspend ()
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"))
57 (defun do-reboot ()
58 "Reboot the computer"
59 (do-with-terminal "sudo reboot"))
61 (defun do-halt ()
62 "Halt the computer"
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)
79 (format t "done~%")