~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to startkde.cmake

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

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