3
# DEFAULT KDE STARTUP SCRIPT ( @KDE_VERSION_STRING@ )
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
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
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"
25
# we have to unset this for Darwin since it will screw up KDE's dynamic-loading
26
unset DYLD_FORCE_FLAT_NAMESPACE
28
# Enable lightweight memory corruption checker
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
36
$bindir|$bindir:*|*:$bindir|*:$bindir:*) ;;
37
*) PATH=$bindir:$PATH; export PATH;;
43
# kdeinit is used to fork off processes which improves memory usage
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
53
# * Then ksmserver is started which takes control of the rest of the startup sequence
55
# The user's personal KDE directory is usually ~/.kde, but this setting
56
# may be overridden by setting KDEHOME.
59
test -n "$KDEHOME" && kdehome=`echo "$KDEHOME"|sed "s,^~/,$HOME/,"`
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
75
kcmfonts General forceFontDPI 0
78
if test $? -ne 0; then
79
xmessage -geometry 500x100 "Could not start kstartupconfig. Check your installation."
81
. $kdehome/share/config/startupconfig
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"
91
if test -n "$kcminputrc_mouse_cursorsize"; then
92
export XCURSOR_SIZE="$kcminputrc_mouse_cursorsize"
96
if test "$kcmrandrrc_display_applyonstartup" = "true"; then
97
# 4 screens is hopefully enough
98
for scrn in 0 1 2 3; do
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}"
105
refresh="\$kcmrandrrc_screen${scrn}_refresh" ; eval "refresh=$refresh"
106
if test -n "${refresh}"; then
107
args="$args -r ${refresh}"
109
rotation="\$kcmrandrrc_screen${scrn}_rotation" ; eval "rotation=$rotation"
110
if test -n "${rotation}"; then
111
case "${rotation}" in
126
reflectx="\$kcmrandrrc_screen${scrn}_reflectx" ; eval "reflectx=$reflectx"
127
if test "${refrectx}" = "true"; then
130
reflecty="\$kcmrandrrc_screen${scrn}_reflecty" ; eval "reflecty=$reflecty"
131
if test "${refrecty}" = "true"; then
134
if test -n "$args"; then
140
if test "$kcmfonts_general_forcefontdpi" -eq 120; then
141
xrdb -quiet -merge -nocpp <<EOF
144
elif test "$kcmfonts_general_forcefontdpi" -eq 96; then
145
xrdb -quiet -merge -nocpp <<EOF
152
unset DESKTOP_LOCKED # Don't want it in the environment
154
if test -z "$dl"; then
155
# the splashscreen and progress indicator
156
case "$ksplashrc_ksplash_engine" in
158
ksplashx ${ksplashrc_ksplash_theme}
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
exepath=`kde4-config --path exe | tr : '\n'`
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"
190
# Activate the kde font directories.
192
# There are 4 directories that may be used for supplying fonts for KDE.
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.
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.
201
# The preference order looks like this:
202
# user override, system override, X, user, system
204
# Where X is the original font database that was set up before this script
207
usr_odir=$HOME/.fonts/kde-override
208
usr_fdir=$HOME/.fonts
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
215
sys_odir=$KDEDIR/share/fonts/override
216
sys_fdir=$KDEDIR/share/fonts
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.
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"
229
# Ask X11 to rebuild its font list.
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.
237
# If the user has overwritten fonts, the cursor font may be different now
238
# so don't move this up.
240
xsetroot -cursor_name left_ptr
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
251
lnusertemp=`kde4-config --path exe --locate lnusertemp`
252
if test -z "$lnusertemp"; then
254
echo 'startkde: ERROR: Could not locate lnusertemp in '`kde4-config --path exe` 1>&2
257
# Link "tmp" "socket" and "cache" resources to directory in /tmp
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."
272
# In case of dcop sockets left by a previous session, cleanup
275
echo 'startkde: Starting up...' 1>&2
277
# Make sure that D-Bus is running, running qdbus will auto-launch it
279
if qdbus >/dev/null 2>/dev/null; then
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."
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
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).
305
KDE_FULL_SESSION=true
306
export KDE_FULL_SESSION
307
xprop -root -f KDE_FULL_SESSION 8t -set KDE_FULL_SESSION true
309
KDE_SESSION_VERSION=4
310
export KDE_SESSION_VERSION
311
xprop -root -f KDE_SESSION_VERSION 32c -set KDE_SESSION_VERSION 4
314
export KDE_SESSION_UID
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
321
echo 'startkde: Could not start kdeinit4. Check your installation.' 1>&2
322
xmessage -geometry 500x100 "Could not start kdeinit4. Check your installation."
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.
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
348
echo 'startkde: Could not start ksmserver. Check your installation.' 1>&2
349
xmessage -geometry 500x100 "Could not start ksmserver. Check your installation."
352
# wait if there's any crashhandler shown
353
while qdbus | grep -q ^[^w]*org.kde.drkonqi ; do
357
echo 'startkde: Shutting down...' 1>&2
362
echo 'startkde: Running shutdown scripts...' 1>&2
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"
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
377
echo 'startkde: Done.' 1>&2