~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy-backports

« back to all changes in this revision

Viewing changes to startkde.cmake

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-09-05 20:45:14 UTC
  • Revision ID: james.westby@ubuntu.com-20070905204514-632hhspl0nvrc84i
Tags: upstream-3.93.0
ImportĀ upstreamĀ versionĀ 3.93.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
#  DEFAULT KDE STARTUP SCRIPT ( @KDE_VERSION_STRING@ )
 
4
#
 
5
 
 
6
# When the X server dies we get a HUP signal from xinit. We must ignore it
 
7
# because we still need to do some cleanup.
 
8
trap 'echo GOT SIGHUP' HUP
 
9
 
 
10
# Check if a KDE session already is running
 
11
if kcheckrunning >/dev/null 2>&1; then
 
12
        echo "KDE seems to be already running on this display."
 
13
        xmessage -geometry 500x100 "KDE seems to be already running on this display." > /dev/null 2>/dev/null
 
14
        exit 1
 
15
fi
 
16
 
 
17
# Set the background to plain grey.
 
18
# The standard X background is nasty, causing moire effects and exploding
 
19
# people's heads. We use colours from the standard KDE palette for those with
 
20
# palettised displays.
 
21
if test -z "$XDM_MANAGED" || echo "$XDM_MANAGED" | grep ",auto" > /dev/null; then
 
22
  xsetroot -solid "#000000"
 
23
fi
 
24
 
 
25
# we have to unset this for Darwin since it will screw up KDE's dynamic-loading
 
26
unset DYLD_FORCE_FLAT_NAMESPACE
 
27
 
 
28
# Enable lightweight memory corruption checker
 
29
MALLOC_CHECK_=2 
 
30
export MALLOC_CHECK_
 
31
 
 
32
# in case we have been started with full pathname spec without being in PATH
 
33
bindir=`echo "$0" | sed -n 's,^\(/.*\)/[^/][^/]*$,\1,p'`
 
34
if [ -n "$bindir" ]; then
 
35
  case $PATH in
 
36
    $bindir|$bindir:*|*:$bindir|*:$bindir:*) ;;
 
37
    *) PATH=$bindir:$PATH; export PATH;;
 
38
  esac
 
39
fi
 
40
 
 
41
# Boot sequence:
 
42
#
 
43
# kdeinit is used to fork off processes which improves memory usage
 
44
# and startup time.
 
45
#
 
46
# * kdeinit starts klauncher first.
 
47
# * Then kded is started. kded is responsible for keeping the sycoca
 
48
#   database up to date. When an up to date database is present it goes
 
49
#   into the background and the startup continues.
 
50
# * Then kdeinit starts kcminit. kcminit performs initialisation of
 
51
#   certain devices according to the user's settings
 
52
#
 
53
# * Then ksmserver is started which takes control of the rest of the startup sequence
 
54
 
 
55
# The user's personal KDE directory is usually ~/.kde, but this setting
 
56
# may be overridden by setting KDEHOME.
 
57
 
 
58
kdehome=$HOME/.kde
 
59
test -n "$KDEHOME" && kdehome=`echo "$KDEHOME"|sed "s,^~/,$HOME/,"`
 
60
 
 
61
# see kstartupconfig source for usage
 
62
mkdir -m 700 -p $kdehome
 
63
mkdir -m 700 -p $kdehome/share
 
64
mkdir -m 700 -p $kdehome/share/config
 
65
cat >$kdehome/share/config/startupconfigkeys <<EOF
 
66
kcminputrc Mouse cursorTheme ''
 
67
kcminputrc Mouse cursorSize ''
 
68
ksplashrc KSplash Theme Default
 
69
ksplashrc KSplash Engine KSplashX
 
70
kcmrandrrc Display ApplyOnStartup false
 
71
kcmrandrrc [Screen0]
 
72
kcmrandrrc [Screen1]
 
73
kcmrandrrc [Screen2]
 
74
kcmrandrrc [Screen3]
 
75
kcmfonts General forceFontDPI 0
 
76
EOF
 
77
kstartupconfig
 
78
if test $? -ne 0; then
 
79
    xmessage -geometry 500x100 "Could not start kstartupconfig. Check your installation."
 
80
fi
 
81
. $kdehome/share/config/startupconfig
 
82
 
 
83
# XCursor mouse theme needs to be applied here to work even for kded or ksmserver
 
84
if test -n "$kcminputrc_mouse_cursortheme" -o -n "$kcminputrc_mouse_cursorsize" ; then
 
85
    kapplymousetheme "$kcminputrc_mouse_cursortheme" "$kcminputrc_mouse_cursorsize"
 
86
    if test $? -eq 10; then
 
87
        export XCURSOR_THEME=default
 
88
    elif test -n "$kcminputrc_mouse_cursortheme"; then
 
89
        export XCURSOR_THEME="$kcminputrc_mouse_cursortheme"
 
90
    fi
 
91
    if test -n "$kcminputrc_mouse_cursorsize"; then
 
92
        export XCURSOR_SIZE="$kcminputrc_mouse_cursorsize"
 
93
    fi
 
94
fi
 
95
 
 
96
if test "$kcmrandrrc_display_applyonstartup" = "true"; then
 
97
    # 4 screens is hopefully enough
 
98
    for scrn in 0 1 2 3; do
 
99
        args=
 
100
        width="\$kcmrandrrc_screen${scrn}_width" ; eval "width=$width"
 
101
        height="\$kcmrandrrc_screen${scrn}_height" ; eval "height=$height"
 
102
        if test -n "${width}" -a -n "${height}"; then
 
103
            args="$args -s ${width}x${height}"
 
104
        fi
 
105
        refresh="\$kcmrandrrc_screen${scrn}_refresh" ; eval "refresh=$refresh"
 
106
        if test -n "${refresh}"; then
 
107
            args="$args -r ${refresh}"
 
108
        fi
 
109
        rotation="\$kcmrandrrc_screen${scrn}_rotation" ; eval "rotation=$rotation"
 
110
        if test -n "${rotation}"; then
 
111
            case "${rotation}" in
 
112
                0)
 
113
                    args="$args -o 0"
 
114
                    ;;
 
115
                90)
 
116
                    args="$args -o 1"
 
117
                    ;;
 
118
                180)
 
119
                    args="$args -o 2"
 
120
                    ;;
 
121
                270)
 
122
                    args="$args -o 3"
 
123
                    ;;
 
124
            esac
 
125
        fi
 
126
        reflectx="\$kcmrandrrc_screen${scrn}_reflectx" ; eval "reflectx=$reflectx"
 
127
        if test "${refrectx}" = "true"; then
 
128
            args="$args -x"
 
129
        fi
 
130
        reflecty="\$kcmrandrrc_screen${scrn}_reflecty" ; eval "reflecty=$reflecty"
 
131
        if test "${refrecty}" = "true"; then
 
132
            args="$args -y"
 
133
        fi
 
134
        if test -n "$args"; then
 
135
            xrandr $args
 
136
        fi
 
137
    done
 
138
fi
 
139
 
 
140
if test "$kcmfonts_general_forcefontdpi" -eq 120; then
 
141
    xrdb -quiet -merge -nocpp <<EOF
 
142
Xft.dpi: 120
 
143
EOF
 
144
elif test "$kcmfonts_general_forcefontdpi" -eq 96; then
 
145
    xrdb -quiet -merge -nocpp <<EOF
 
146
Xft.dpi: 96
 
147
EOF
 
148
fi
 
149
 
 
150
 
 
151
dl=$DESKTOP_LOCKED
 
152
unset DESKTOP_LOCKED # Don't want it in the environment
 
153
 
 
154
if test -z "$dl"; then
 
155
  # the splashscreen and progress indicator
 
156
  case "$ksplashrc_ksplash_engine" in
 
157
    KSplashX)
 
158
      ksplashx ${ksplashrc_ksplash_theme}
 
159
      ;;
 
160
    None)
 
161
      ;;
 
162
    Simple)
 
163
      ksplashsimple
 
164
      ;;
 
165
    *)
 
166
      ;;
 
167
  esac
 
168
fi
 
169
 
 
170
# Source scripts found in <localprefix>/env/*.sh and <prefixes>/env/*.sh
 
171
# (where <localprefix> is $KDEHOME or ~/.kde, and <prefixes> is where KDE is installed)
 
172
#
 
173
# This is where you can define environment variables that will be available to
 
174
# all KDE programs, so this is where you can run agents using e.g. eval `ssh-agent`
 
175
# or eval `gpg-agent --daemon`.
 
176
# Note: if you do that, you should also put "ssh-agent -k" as a shutdown script
 
177
#
 
178
# (see end of this file).
 
179
# For anything else (that doesn't set env vars, or that needs a window manager),
 
180
# better use the Autostart folder.
 
181
 
 
182
exepath=`kde4-config --path exe | tr : '\n'`
 
183
 
 
184
for prefix in `echo "$exepath" | sed -n -e 's,/bin[^/]*/,/env/,p'`; do
 
185
  for file in "$prefix"*.sh; do
 
186
    test -r "$file" && . "$file"
 
187
  done
 
188
done
 
189
 
 
190
# Activate the kde font directories.
 
191
#
 
192
# There are 4 directories that may be used for supplying fonts for KDE.
 
193
#
 
194
# There are two system directories. These belong to the administrator.
 
195
# There are two user directories, where the user may add her own fonts.
 
196
#
 
197
# The 'override' versions are for fonts that should come first in the list,
 
198
# i.e. if you have a font in your 'override' directory, it will be used in
 
199
# preference to any other.
 
200
#
 
201
# The preference order looks like this:
 
202
# user override, system override, X, user, system
 
203
#
 
204
# Where X is the original font database that was set up before this script
 
205
# runs.
 
206
 
 
207
usr_odir=$HOME/.fonts/kde-override
 
208
usr_fdir=$HOME/.fonts
 
209
 
 
210
if test -n "$KDEDIRS"; then
 
211
  kdedirs_first=`echo "$KDEDIRS"|sed -e 's/:.*//'`
 
212
  sys_odir=$kdedirs_first/share/fonts/override
 
213
  sys_fdir=$kdedirs_first/share/fonts
 
214
else
 
215
  sys_odir=$KDEDIR/share/fonts/override
 
216
  sys_fdir=$KDEDIR/share/fonts
 
217
fi
 
218
 
 
219
# We run mkfontdir on the user's font dirs (if we have permission) to pick
 
220
# up any new fonts they may have installed. If mkfontdir fails, we still
 
221
# add the user's dirs to the font path, as they might simply have been made
 
222
# read-only by the administrator, for whatever reason.
 
223
 
 
224
test -d "$sys_odir" && xset +fp "$sys_odir"
 
225
test -d "$usr_odir" && (mkfontdir "$usr_odir" ; xset +fp "$usr_odir")
 
226
test -d "$usr_fdir" && (mkfontdir "$usr_fdir" ; xset fp+ "$usr_fdir")
 
227
test -d "$sys_fdir" && xset fp+ "$sys_fdir"
 
228
 
 
229
# Ask X11 to rebuild its font list.
 
230
xset fp rehash
 
231
 
 
232
# Set a left cursor instead of the standard X11 "X" cursor, since I've heard
 
233
# from some users that they're confused and don't know what to do. This is
 
234
# especially necessary on slow machines, where starting KDE takes one or two
 
235
# minutes until anything appears on the screen.
 
236
#
 
237
# If the user has overwritten fonts, the cursor font may be different now
 
238
# so don't move this up.
 
239
#
 
240
xsetroot -cursor_name left_ptr
 
241
 
 
242
# Get Ghostscript to look into user's KDE fonts dir for additional Fontmap
 
243
if test -n "$GS_LIB" ; then
 
244
    GS_LIB=$usr_fdir:$GS_LIB
 
245
    export GS_LIB
 
246
else
 
247
    GS_LIB=$usr_fdir
 
248
    export GS_LIB
 
249
fi
 
250
 
 
251
lnusertemp=`kde4-config --path exe --locate lnusertemp`
 
252
if test -z "$lnusertemp"; then
 
253
  # Startup error
 
254
  echo 'startkde: ERROR: Could not locate lnusertemp in '`kde4-config --path exe` 1>&2
 
255
fi
 
256
 
 
257
# Link "tmp" "socket" and "cache" resources to directory in /tmp
 
258
# Creates:
 
259
# - a directory /tmp/kde-$USER and links $KDEHOME/tmp-$HOSTNAME to it.
 
260
# - a directory /tmp/ksocket-$USER and links $KDEHOME/socket-$HOSTNAME to it.
 
261
# - a directory /var/tmp/kdecache-$USER and links $KDEHOME/cache-$HOSTNAME to it.
 
262
# Note: temporary locations can be overriden through the KDETMP and KDEVARTMP
 
263
# environment variables
 
264
for resource in tmp cache socket; do
 
265
    if ! "$lnusertemp" $resource >/dev/null; then
 
266
        echo 'startkde: Call to lnusertemp failed (temporary directories full?). Check your installation.'  1>&2
 
267
        xmessage -geometry 600x100 "Call to lnusertemp failed (temporary directories full?). Check your installation."
 
268
        exit 1
 
269
    fi
 
270
done
 
271
 
 
272
# In case of dcop sockets left by a previous session, cleanup
 
273
#dcopserver_shutdown
 
274
 
 
275
echo 'startkde: Starting up...'  1>&2
 
276
 
 
277
# Make sure that D-Bus is running, running qdbus will auto-launch it
 
278
# if it is not
 
279
if qdbus >/dev/null 2>/dev/null; then
 
280
    : # ok
 
281
else
 
282
    echo 'startkde: Could not start D-Bus. Check your installation.'  1>&2
 
283
    xmessage -geometry 500x100 "Could not start D-Bus. Check your installation."
 
284
fi
 
285
 
 
286
 
 
287
# Mark that full KDE session is running (e.g. Konqueror preloading works only
 
288
# with full KDE running). The KDE_FULL_SESSION property can be detected by
 
289
# any X client connected to the same X session, even if not launched
 
290
# directly from the KDE session but e.g. using "ssh -X", kdesu. $KDE_FULL_SESSION
 
291
# however guarantees that the application is launched in the same environment
 
292
# like the KDE session and that e.g. KDE utilities/libraries are available.
 
293
# KDE_FULL_SESSION property is also only available since KDE 3.5.5.
 
294
# The matching tests are:
 
295
#   For $KDE_FULL_SESSION:
 
296
#     if test -n "$KDE_FULL_SESSION"; then ... whatever
 
297
#   For KDE_FULL_SESSION property:
 
298
#     xprop -root | grep "^KDE_FULL_SESSION" >/dev/null 2>/dev/null
 
299
#     if test $? -eq 0; then ... whatever
 
300
#
 
301
# Additionally there is (since KDE 3.5.7) $KDE_SESSION_UID with the uid
 
302
# of the user running the KDE session. It should be rarely needed (e.g.
 
303
# after sudo to prevent desktop-wide functionality in the new user's kded).
 
304
#
 
305
KDE_FULL_SESSION=true
 
306
export KDE_FULL_SESSION
 
307
xprop -root -f KDE_FULL_SESSION 8t -set KDE_FULL_SESSION true
 
308
 
 
309
KDE_SESSION_VERSION=4
 
310
export KDE_SESSION_VERSION
 
311
xprop -root -f KDE_SESSION_VERSION 32c -set KDE_SESSION_VERSION 4
 
312
 
 
313
KDE_SESSION_UID=$UID
 
314
export KDE_SESSION_UID
 
315
 
 
316
# We set LD_BIND_NOW to increase the efficiency of kdeinit.
 
317
# kdeinit unsets this variable before loading applications.
 
318
LD_BIND_NOW=true kdeinit4 +kcminit_startup
 
319
if test $? -ne 0; then
 
320
  # Startup error
 
321
  echo 'startkde: Could not start kdeinit4. Check your installation.'  1>&2
 
322
  xmessage -geometry 500x100 "Could not start kdeinit4. Check your installation."
 
323
fi
 
324
 
 
325
# If the session should be locked from the start (locked autologin),
 
326
# lock now and do the rest of the KDE startup underneath the locker.
 
327
if test -n "$dl"; then
 
328
  kwrapper4 krunner_lock --forcelock &
 
329
  # Give it some time for starting up. This is somewhat unclean; some
 
330
  # notification would be better.
 
331
  sleep 1
 
332
fi
 
333
 
 
334
# finally, give the session control to the session manager
 
335
# see kdebase/ksmserver for the description of the rest of the startup sequence
 
336
# if the KDEWM environment variable has been set, then it will be used as KDE's
 
337
# window manager instead of kwin.
 
338
# if KDEWM is not set, ksmserver will ensure kwin is started.
 
339
# kwrapper4 is used to reduce startup time and memory usage
 
340
# kwrapper4 does not return useful error codes such as the exit code of ksmserver.
 
341
# We only check for 255 which means that the ksmserver process could not be 
 
342
# started, any problems thereafter, e.g. ksmserver failing to initialize, 
 
343
# will remain undetected.
 
344
test -n "$KDEWM" && KDEWM="--windowmanager $KDEWM"
 
345
kwrapper4 ksmserver $KDEWM 
 
346
if test $? -eq 255; then
 
347
  # Startup error
 
348
  echo 'startkde: Could not start ksmserver. Check your installation.'  1>&2
 
349
  xmessage -geometry 500x100 "Could not start ksmserver. Check your installation."
 
350
fi
 
351
 
 
352
# wait if there's any crashhandler shown
 
353
while qdbus | grep -q ^[^w]*org.kde.drkonqi ; do
 
354
    sleep 5
 
355
done
 
356
 
 
357
echo 'startkde: Shutting down...'  1>&2
 
358
 
 
359
# Clean up
 
360
kdeinit4_shutdown
 
361
 
 
362
echo 'startkde: Running shutdown scripts...'  1>&2
 
363
 
 
364
# Run scripts found in $KDEDIRS/shutdown
 
365
for prefix in `echo "$exepath" | sed -n -e 's,/bin[^/]*/,/shutdown/,p'`; do
 
366
  for file in `ls "$prefix" 2> /dev/null | egrep -v '(~|\.bak)$'`; do
 
367
    test -x "$prefix$file" && "$prefix$file"
 
368
  done
 
369
done
 
370
 
 
371
unset KDE_FULL_SESSION
 
372
xprop -root -remove KDE_FULL_SESSION
 
373
unset KDE_SESSION_VERSION
 
374
xprop -root -remove KDE_SESSION_VERSION
 
375
unset KDE_SESSION_UID
 
376
 
 
377
echo 'startkde: Done.'  1>&2