3
# DEFAULT KDE STARTUP SCRIPT ( @KDE_VERSION_STRING@ )
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
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
16
# Check if a KDE session already is running and whether it's possible to connect to X
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
23
elif test $kcheckrunning_result -eq 2 ; then
24
echo "\$DISPLAY is not set or cannot connect to the X server."
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"
36
# we have to unset this for Darwin since it will screw up KDE's dynamic-loading
37
unset DYLD_FORCE_FLAT_NAMESPACE
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')
45
MALLOC_CHECK_=2 # Default to 2 unless glibc 2.9 or higher.
46
test $glibc_version \> 2.08 && MALLOC_CHECK_=3
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
57
$qbindir|$qbindir:*|*:$qbindir|*:$qbindir:*) ;;
58
*) PATH=$qbindir:$PATH; export PATH;;
62
$bindir|$bindir:*|*:$bindir|*:$bindir:*) ;;
63
*) PATH=$bindir:$PATH; export PATH;;
69
# kdeinit is used to fork off processes which improves memory usage
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
79
# * Then ksmserver is started which takes control of the rest of the startup sequence
81
# The user's personal KDE directory is usually ~/.kde, but this setting
82
# may be overridden by setting KDEHOME.
84
kdehome=$HOME/@KDE_DEFAULT_HOME@
85
test -n "$KDEHOME" && kdehome=`echo "$KDEHOME"|sed "s,^~/,$HOME/,"`
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 ''
102
kcmfonts General forceFontDPI 0
103
kdeglobals Locale Language '' # trigger requesting languages from KLocale
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."
111
[ -r $kdehome/share/config/startupconfig ] && . $kdehome/share/config/startupconfig
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@
117
kapplymousetheme "$kcminputrc_mouse_cursortheme" "$kcminputrc_mouse_cursorsize"
118
if test $? -eq 10; then
119
XCURSOR_THEME=default
121
elif test -n "$kcminputrc_mouse_cursortheme"; then
122
XCURSOR_THEME="$kcminputrc_mouse_cursortheme"
125
if test -n "$kcminputrc_mouse_cursorsize"; then
126
XCURSOR_SIZE="$kcminputrc_mouse_cursorsize"
133
if test "$kcmfonts_general_forcefontdpi" -eq 120; then
134
xrdb -quiet -merge -nocpp <<EOF
137
elif test "$kcmfonts_general_forcefontdpi" -eq 96; then
138
xrdb -quiet -merge -nocpp <<EOF
145
unset DESKTOP_LOCKED # Don't want it in the environment
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
156
ksplash_pid=`ksplashx "${ksplashrc_ksplash_theme}" --pid`
161
ksplash_pid=`ksplashsimple "${ksplashrc_ksplash_theme}" --pid`
166
# no longer needed in the environment
167
unset KLOCALE_LANGUAGES
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)
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
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.
182
libpath=`kde4-config --path lib | tr : '\n'`
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"
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
194
# Activate the kde font directories.
196
# There are 4 directories that may be used for supplying fonts for KDE.
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.
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.
205
# The preference order looks like this:
206
# user override, system override, X, user, system
208
# Where X is the original font database that was set up before this script
211
usr_odir=$HOME/.fonts/kde-override
212
usr_fdir=$HOME/.fonts
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
219
sys_odir=$KDEDIR/share/fonts/override
220
sys_fdir=$KDEDIR/share/fonts
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.
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"
233
# Ask X11 to rebuild its font list.
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.
241
# If the user has overwritten fonts, the cursor font may be different now
242
# so don't move this up.
244
xsetroot -cursor_name left_ptr
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
255
lnusertemp=`kde4-config --path exe --locate lnusertemp`
256
if test -z "$lnusertemp"; then
258
echo 'startkde: ERROR: Could not locate lnusertemp in '`kde4-config --path exe` 1>&2
261
# Link "tmp" "socket" and "cache" resources to directory in /tmp
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
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."
279
# In case of dcop sockets left by a previous session, cleanup
282
echo 'startkde: Starting up...' 1>&2
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"
289
# D-Bus autolaunch is broken
290
if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
291
eval `dbus-launch --sh-syntax --exit-with-session`
293
if qdbus >/dev/null 2>/dev/null; then
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?"
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
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).
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.
325
KDE_FULL_SESSION=true
326
export KDE_FULL_SESSION
327
xprop -root -f KDE_FULL_SESSION 8t -set KDE_FULL_SESSION true
329
KDE_SESSION_VERSION=4
330
export KDE_SESSION_VERSION
331
xprop -root -f KDE_SESSION_VERSION 32c -set KDE_SESSION_VERSION 4
333
KDE_SESSION_UID=`id -ru`
334
export KDE_SESSION_UID
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
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."
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
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
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."
375
# wait if there's any crashhandler shown
376
while qdbus | grep "^[^w]*org.kde.drkonqi" > /dev/null ; do
380
echo 'startkde: Shutting down...' 1>&2
382
test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null
387
kde3 kdeinit_shutdown 2>/dev/null
388
kde3 dcopserver_shutdown --wait 2>/dev/null
390
echo 'startkde: Running shutdown scripts...' 1>&2
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"
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
405
echo 'startkde: Done.' 1>&2