source: lliurex-rpi-packages/trunk/fuentes/ldm/ltsp/xinitrc @ 2328

Last change on this file since 2328 was 2328, checked in by kbut, 3 years ago

add new package

  • Property svn:executable set to *
File size: 3.4 KB
Line 
1#!/bin/sh
2#
3#  Copyright (c) 2008 Gideon Romm <ltsp@symbio-technologies.com>
4#
5#  2008, Vagrant Cascadian <vagrant@freegeek.org>
6#
7#  This program is free software; you can redistribute it and/or
8#  modify it under the terms of the GNU General Public License as
9#  published by the Free Software Foundation; either version 2 of the
10#  License, or (at your option) any later version.
11#
12#  This program is distributed in the hope that it will be useful,
13#  but WITHOUT ANY WARRANTY; without even the implied warranty of
14#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15#  GNU General Public License for more details.
16#
17#  You should have received a copy of the GNU General Public License
18#  along with this program.  If not, you can find it on the World Wide
19#  Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
20#  Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
21#  MA 02110-1301, USA.
22#
23
24# xinit won't allow "--" to be used in the command line of the client:
25#   xinit [ [ client ] options ... ] [ -- [ server ] [ display ] options ... ]
26# Moreover, the lts.conf SCREEN_XX variables are usually formatted using a
27# quoted shell-like syntax, and they require either eval or sourcing in order
28# to be properly evaluated.
29# For those reasons, screen.d scripts should pass a single argument to
30# xinitrc, e.g.:
31#   xinit /usr/share/ltsp/xinitrc "$* $LTS_OPTION1 $LTS_OPTION2"
32# And that command will then be executed by xinitrc using eval.
33# Note though that when xinitrc isn't present, screen scripts should use eval
34# themselves instead (while losing the ability to pass "--" to programs), e.g.:
35#   eval xinit "$* $LTS_OPTION1 $LTS_OPTION2"
36# Quoting the parameters is necessary in both cases to avoid glob expansion.
37
38. /usr/share/ltsp/ltsp-client-functions
39
40XINITRCDIR=/usr/share/ltsp/xinitrc.d
41
42COMMAND=$*
43
44export COMMAND
45
46# use run-parts to source every file in the xinitrc directory; we source
47# instead of executing so that the variables and functions defined above
48# are available to the scripts, and so that they can pass variables to each
49# other
50XINITRCFILES=$(run_parts_list $XINITRCDIR)
51if [ -n "$XINITRCFILES" ]; then
52  set +e
53  for XINITRCFILE in $XINITRCFILES; do
54    . $XINITRCFILE
55  done
56  set -e
57fi
58
59if boolean_is_true "$XINITRC_DAEMON"; then
60    set +e
61    # Make the arrow aa bit more presentable.  :)
62    xsetroot -cursor_name top_left_arrow
63    unset BREAK_LOOP
64    while [ -z "$BREAK_LOOP" ]; do
65        # Quotes prevent possible glob expansion before the eval call
66        eval "$COMMAND"
67        ret=$?
68        if [ "$ret" != "0" ]; then
69            if [ -z "$XINITRC_COMMAND_ON_ERROR" ]; then
70                XINITRC_COMMAND_ON_ERROR="ldm-dialog --message \"An error has occured.\"" 
71            fi
72            if boolean_is_true "$XINITRC_PROMPT_ON_ERROR"; then
73                for i in $XINITRC_ERROR_CODES; do
74                    if [ "$i" = "$ret" ]; then
75                        eval ${XINITRC_COMMAND_ON_ERROR} 2>/dev/null || true
76                    fi
77                done
78            fi
79        else
80            if boolean_is_true "$XINITRC_PROMPT_ON_EXIT"; then
81                ldm-dialog --question "Would you like to start this session?" 2>/dev/null || true
82                [ "$?" != 0 ] && BREAK_LOOP=1
83            fi
84        fi
85    done
86    [ -n "$XINITRC_COMMAND_ON_EXIT" ] && eval ${XINITRC_COMMAND_ON_EXIT}
87    set -e
88else
89    eval "exec $COMMAND"
90fi
Note: See TracBrowser for help on using the repository browser.