chiark / gitweb /
Imported Upstream version 1.0.0
[e16] / scripts / session.sh
1 #!/bin/sh
2 #
3 # Default script for e16 session start/restart/stop management
4 #
5 # Assuming misc.session.enable_script is set and misc.session.script
6 # points to this script it will be called with parameter
7 #
8 # - "init"  first time an X-session (with e16) starts
9 # - "start" every time e16 (re)starts
10 # - "stop"  when e16 exits without restarting
11 #
12 # On init, start, and stop the script will run any executable found in
13 # ~/.e16/Init/, ~/.e16/Start/, and ~/.e16/Stop/, respectively.
14 # These executables do not have to exit as they are called with '&' from here.
15 #
16 # NOTE:
17 # In multi-display/screen setups the DISPLAY environment variable can be used
18 # to differentiate.
19 #
20
21 #echo $DISPLAY
22
23 RunApps() {
24         local d;
25
26         d="$ECONFDIR/$1"
27         test -d "$d" || return
28
29         for f in "$d"/*
30         do
31                 if [ -x "$f" ]; then
32 #                       echo $f
33                         case "$f" in
34                         *~)     # Assume this is crap - skip
35                                 ;;
36                         *.sh)   # Scripts are executed in foreground
37                                 "$f"
38                                 ;;
39                         *)      # Anything else is executed in background
40                                 "$f"  &
41                                 ;;
42                         esac
43                 fi
44         done
45 }
46
47
48 case "$1" in
49 init)
50         RunApps Init
51         ;;
52 start)
53         RunApps Start
54         ;;
55 stop)
56         RunApps Stop
57         ;;
58 esac