src/clfswm-util.lisp (update-menus): Follow XDG specifications instead of the non...
[clfswm.git] / contrib / clfswm
blob6f25140b069f39c00a606660110650089bfb3cef
1 #!/bin/bash -e
3 # (C) 2008 Xavier Maillard <xma@gnu.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 # --------------------------------------------------------------------------
21 # Documentation:
23 # Original code and idea: http://stumpwm.antidesktop.net/cgi-bin/wiki/SetUp
25 # Installation:
26 # Put this script wherever you want and just call it from your .xinitrc file
28 # The first time you will launch it, it will build the final
29 # executable and then call it. To force a rebuild of your executable
30 # (say you have updated something in the CLFSWM source tree), just
31 # delete the image and restart your X session.
32 # --------------------------------------------------------------------------
34 usage() {
36 echo "$0 [options]
38 n,no-start don't start CLFSWM after image dump
39 f,force force image dump
40 rebuild same as -f,--force
41 l,with-lisp= use <lisp> as the common lisp implementation
42 d,dump-path= path to the dump directory
43 with-clfswm path to clfswm.asd file
44 with-asdf path to the asdf.lisp file"
46 exit 0
49 die() {
50 echo >&2 "$@"
51 exit 1
54 build_clisp ()
56 clisp -m 8MB -E ISO-8859-1 -q -K full -i $asdf_path/asdf.lisp -x "(asdf:oos 'asdf:load-op :clfswm)\
57 (EXT:SAVEINITMEM \"$dump_image\" :INIT-FUNCTION 'clfswm:main :EXECUTABLE t :norc t)"
60 build_sbcl()
62 sbcl --disable-debugger --eval "(mapc 'require '(asdf clfswm))" \
63 --eval "(save-lisp-and-die \"$dump_image\" :toplevel 'clfswm:main)"
66 no_start=no
67 lisp=clisp
68 dump_path=$HOME/var/cache
69 asdf_path=$HOME/usr/src/SVNed/clfswm
70 clfswm_asd_path=$HOME/usr/share/common-lisp/systems
72 while test $# != 0
74 case "$1" in
75 -n|--no-start)
76 no_start=yes ;;
77 -f|--force|--rebuild)
78 force=yes ;;
79 -d|--dump-path)
80 shift
81 dump_path="$1" ;;
82 --with-clfswm)
83 shift
84 clfswm_asd_path="$1" ;;
85 --with-asdf)
86 shift
87 asdf_path="$1" ;;
88 -l|--with-lisp)
89 shift
90 case "$1" in
91 '')
92 usage;;
93 clisp|sbcl)
94 lisp="$1" ;;
95 esac
97 --)
98 shift
99 break ;;
101 usage ;;
102 esac
103 shift
104 done
107 dump_image="$dump_path/clfswm-$(cksum $(type -p $lisp) | cut -d ' ' -f 1).core"
109 if test yes = "$force" && test -e "$dump_image"
110 then
111 echo "Removing old image."
112 rm -f "$dump_image"
115 if test ! -e "$dump_image" ||
116 ( for i in "$(dirname $(readlink $clfswm_asd_path/clfswm.asd))"/*.lisp
117 do test "$dump_image" -ot "$i" && exit 1
118 done )
119 then
120 test -x $(type -p $lisp) || die "$lisp can't be found."
121 test -e $clfswm_asd_path/clfswm.asd || die "can't find clfswm.asd in $clfswm_asd_path"
122 test -e $asdf_path/asdf.lisp || die "can't find asdf.lisp in $asdf_path"
124 eval build_$lisp
127 # Run the resulting image
128 if test no = "$no_start"
129 then
130 case $lisp in
131 clisp ) $dump_image ;;
132 sbcl ) exec sbcl --core "$dump_image" ;;
133 *) echo "..." ;;
134 esac
135 else
136 echo "As requested, we have just dumped the image."