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 and whether it's possible to connect to X
12 kcheckrunning_result
=$?
13 if test $kcheckrunning_result -eq 0 ; then
14 echo "KDE seems to be already running on this display."
15 xmessage
-geometry 500x100
"KDE seems to be already running on this display." > /dev
/null
2>/dev
/null
17 elif test $kcheckrunning_result -eq 2 ; then
18 echo "\$DISPLAY is not set or cannot connect to the X server."
22 # Set the background to plain grey.
23 # The standard X background is nasty, causing moire effects and exploding
24 # people's heads. We use colours from the standard KDE palette for those with
25 # palettised displays.
26 if test -z "$XDM_MANAGED" ||
echo "$XDM_MANAGED" |
grep ",auto" > /dev
/null
; then
27 xsetroot
-solid "#000000"
30 # we have to unset this for Darwin since it will screw up KDE's dynamic-loading
31 unset DYLD_FORCE_FLAT_NAMESPACE
33 # Enable lightweight memory corruption checker
37 # in case we have been started with full pathname spec without being in PATH
38 bindir
=`echo "$0" | sed -n 's,^\(/.*\)/[^/][^/]*$,\1,p'`
39 if [ -n "$bindir" ]; then
40 qbindir
=`$bindir/kde4-config --qt-binaries`
41 if [ -n "$qbindir" ]; then
43 $qbindir|
$qbindir:*|
*:$qbindir|
*:$qbindir:*) ;;
44 *) PATH
=$qbindir:$PATH; export PATH
;;
48 $bindir|
$bindir:*|
*:$bindir|
*:$bindir:*) ;;
49 *) PATH
=$bindir:$PATH; export PATH
;;
55 # kdeinit is used to fork off processes which improves memory usage
58 # * kdeinit starts klauncher first.
59 # * Then kded is started. kded is responsible for keeping the sycoca
60 # database up to date. When an up to date database is present it goes
61 # into the background and the startup continues.
62 # * Then kdeinit starts kcminit. kcminit performs initialisation of
63 # certain devices according to the user's settings
65 # * Then ksmserver is started which takes control of the rest of the startup sequence
67 # The user's personal KDE directory is usually ~/.kde, but this setting
68 # may be overridden by setting KDEHOME.
70 kdehome
=$HOME/@KDE_DEFAULT_HOME@
71 test -n "$KDEHOME" && kdehome
=`echo "$KDEHOME"|sed "s,^~/,$HOME/,"`
73 # see kstartupconfig source for usage
74 mkdir
-m 700 -p $kdehome
75 mkdir
-m 700 -p $kdehome/share
76 mkdir
-m 700 -p $kdehome/share
/config
77 cat >$kdehome/share
/config
/startupconfigkeys
<<EOF
78 kcminputrc Mouse cursorTheme 'Oxygen_Black'
79 kcminputrc Mouse cursorSize ''
80 ksplashrc KSplash Theme Default
81 ksplashrc KSplash Engine KSplashX
82 kcmrandrrc Display ApplyOnStartup false
87 kcmfonts General forceFontDPI 0
88 kdeglobals Locale Language '' # trigger requesting languages from KLocale
92 if test $returncode -ne 0; then
93 xmessage
-geometry 500x100
"kstartupconfig4 does not exist or fails. The error code is $returncode. Check your installation."
96 [ -r $kdehome/share
/config
/startupconfig
] && .
$kdehome/share
/config
/startupconfig
98 # XCursor mouse theme needs to be applied here to work even for kded or ksmserver
99 if test -n "$kcminputrc_mouse_cursortheme" -o -n "$kcminputrc_mouse_cursorsize" ; then
100 @EXPORT_XCURSOR_PATH@
102 kapplymousetheme
"$kcminputrc_mouse_cursortheme" "$kcminputrc_mouse_cursorsize"
103 if test $?
-eq 10; then
104 XCURSOR_THEME
=default
106 elif test -n "$kcminputrc_mouse_cursortheme"; then
107 XCURSOR_THEME
="$kcminputrc_mouse_cursortheme"
110 if test -n "$kcminputrc_mouse_cursorsize"; then
111 XCURSOR_SIZE
="$kcminputrc_mouse_cursorsize"
116 if test "$kcmrandrrc_display_applyonstartup" = "true"; then
117 # 4 screens is hopefully enough
118 for scrn
in 0 1 2 3; do
120 width
="\$kcmrandrrc_screen${scrn}_width" ; eval "width=$width"
121 height
="\$kcmrandrrc_screen${scrn}_height" ; eval "height=$height"
122 if test -n "${width}" -a -n "${height}"; then
123 args
="$args -s ${width}x${height}"
125 refresh
="\$kcmrandrrc_screen${scrn}_refresh" ; eval "refresh=$refresh"
126 if test -n "${refresh}"; then
127 args
="$args -r ${refresh}"
129 rotation
="\$kcmrandrrc_screen${scrn}_rotation" ; eval "rotation=$rotation"
130 if test -n "${rotation}"; then
131 case "${rotation}" in
146 reflectx
="\$kcmrandrrc_screen${scrn}_reflectx" ; eval "reflectx=$reflectx"
147 if test "${refrectx}" = "true"; then
150 reflecty
="\$kcmrandrrc_screen${scrn}_reflecty" ; eval "reflecty=$reflecty"
151 if test "${refrecty}" = "true"; then
154 if test -n "$args"; then
160 if test "$kcmfonts_general_forcefontdpi" -eq 120; then
161 xrdb
-quiet -merge -nocpp <<EOF
164 elif test "$kcmfonts_general_forcefontdpi" -eq 96; then
165 xrdb
-quiet -merge -nocpp <<EOF
172 unset DESKTOP_LOCKED
# Don't want it in the environment
175 if test -z "$dl"; then
176 # languages as resolved by KLocale, for the splash screens use
177 # klocale_languages is assembled by kdostartupconfig4 calling KLocale
178 KLOCALE_LANGUAGES
="$klocale_languages"
179 export KLOCALE_LANGUAGES
180 # the splashscreen and progress indicator
181 case "$ksplashrc_ksplash_engine" in
183 ksplash_pid
=`ksplashx "${ksplashrc_ksplash_theme}" --pid`
188 ksplash_pid
=`ksplashsimple "${ksplashrc_ksplash_theme}" --pid`
193 # no longer needed in the environment
194 unset KLOCALE_LANGUAGES
197 # Source scripts found in <localprefix>/env/*.sh and <prefixes>/env/*.sh
198 # (where <localprefix> is $KDEHOME or ~/.kde, and <prefixes> is where KDE is installed)
200 # This is where you can define environment variables that will be available to
201 # all KDE programs, so this is where you can run agents using e.g. eval `ssh-agent`
202 # or eval `gpg-agent --daemon`.
203 # Note: if you do that, you should also put "ssh-agent -k" as a shutdown script
205 # (see end of this file).
206 # For anything else (that doesn't set env vars, or that needs a window manager),
207 # better use the Autostart folder.
209 libpath
=`kde4-config --path lib | tr : '\n'`
211 for prefix
in `echo "$libpath" | sed -n -e 's,/lib[^/]*/,/env/,p'`; do
212 for file in "$prefix"*.sh
; do
213 test -r "$file" && .
"$file"
217 # Set the path for Qt plugins provided by KDE
218 if test -n "$QT_PLUGIN_PATH"; then
219 QT_PLUGIN_PATH
="$QT_PLUGIN_PATH:`kde4-config --path qtplugins`"
221 QT_PLUGIN_PATH
="`kde4-config --path qtplugins`"
223 export QT_PLUGIN_PATH
225 # Activate the kde font directories.
227 # There are 4 directories that may be used for supplying fonts for KDE.
229 # There are two system directories. These belong to the administrator.
230 # There are two user directories, where the user may add her own fonts.
232 # The 'override' versions are for fonts that should come first in the list,
233 # i.e. if you have a font in your 'override' directory, it will be used in
234 # preference to any other.
236 # The preference order looks like this:
237 # user override, system override, X, user, system
239 # Where X is the original font database that was set up before this script
242 usr_odir
=$HOME/.fonts
/kde-override
243 usr_fdir
=$HOME/.fonts
245 if test -n "$KDEDIRS"; then
246 kdedirs_first
=`echo "$KDEDIRS"|sed -e 's/:.*//'`
247 sys_odir
=$kdedirs_first/share
/fonts
/override
248 sys_fdir
=$kdedirs_first/share
/fonts
250 sys_odir
=$KDEDIR/share
/fonts
/override
251 sys_fdir
=$KDEDIR/share
/fonts
254 # We run mkfontdir on the user's font dirs (if we have permission) to pick
255 # up any new fonts they may have installed. If mkfontdir fails, we still
256 # add the user's dirs to the font path, as they might simply have been made
257 # read-only by the administrator, for whatever reason.
259 test -d "$sys_odir" && xset
+fp
"$sys_odir"
260 test -d "$usr_odir" && (mkfontdir
"$usr_odir" ; xset
+fp
"$usr_odir")
261 test -d "$usr_fdir" && (mkfontdir
"$usr_fdir" ; xset fp
+ "$usr_fdir")
262 test -d "$sys_fdir" && xset fp
+ "$sys_fdir"
264 # Ask X11 to rebuild its font list.
267 # Set a left cursor instead of the standard X11 "X" cursor, since I've heard
268 # from some users that they're confused and don't know what to do. This is
269 # especially necessary on slow machines, where starting KDE takes one or two
270 # minutes until anything appears on the screen.
272 # If the user has overwritten fonts, the cursor font may be different now
273 # so don't move this up.
275 xsetroot
-cursor_name left_ptr
277 # Get Ghostscript to look into user's KDE fonts dir for additional Fontmap
278 if test -n "$GS_LIB" ; then
279 GS_LIB
=$usr_fdir:$GS_LIB
286 lnusertemp
=`kde4-config --path exe --locate lnusertemp`
287 if test -z "$lnusertemp"; then
289 echo 'startkde: ERROR: Could not locate lnusertemp in '`kde4-config --path exe` 1>&2
292 # Link "tmp" "socket" and "cache" resources to directory in /tmp
294 # - a directory /tmp/kde-$USER and links $KDEHOME/tmp-$HOSTNAME to it.
295 # - a directory /tmp/ksocket-$USER and links $KDEHOME/socket-$HOSTNAME to it.
296 # - a directory /var/tmp/kdecache-$USER and links $KDEHOME/cache-$HOSTNAME to it.
297 # Note: temporary locations can be overriden through the KDETMP and KDEVARTMP
298 # environment variables
299 for resource
in tmp cache socket
; do
300 if "$lnusertemp" $resource >/dev
/null
; then
303 echo 'startkde: Call to lnusertemp failed (temporary directories full?). Check your installation.' 1>&2
304 test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev
/null
305 xmessage
-geometry 600x100
"Call to lnusertemp failed (temporary directories full?). Check your installation."
310 # In case of dcop sockets left by a previous session, cleanup
313 echo 'startkde: Starting up...' 1>&2
315 # Make sure that D-Bus is running
316 if test -z "$XDG_DATA_DIRS"; then
317 XDG_DATA_DIRS
="`kde4-config --prefix`/share:/usr/share:/usr/local/share"
320 # D-Bus autolaunch is broken
321 if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
322 eval `dbus-launch --sh-syntax --exit-with-session`
324 if qdbus
>/dev
/null
2>/dev
/null
; then
327 echo 'startkde: Could not start D-Bus. Check your installation.' 1>&2
328 test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev
/null
329 xmessage
-geometry 500x100
"Could not start D-Bus. Check your installation."
334 # Mark that full KDE session is running (e.g. Konqueror preloading works only
335 # with full KDE running). The KDE_FULL_SESSION property can be detected by
336 # any X client connected to the same X session, even if not launched
337 # directly from the KDE session but e.g. using "ssh -X", kdesu. $KDE_FULL_SESSION
338 # however guarantees that the application is launched in the same environment
339 # like the KDE session and that e.g. KDE utilities/libraries are available.
340 # KDE_FULL_SESSION property is also only available since KDE 3.5.5.
341 # The matching tests are:
342 # For $KDE_FULL_SESSION:
343 # if test -n "$KDE_FULL_SESSION"; then ... whatever
344 # For KDE_FULL_SESSION property:
345 # xprop -root | grep "^KDE_FULL_SESSION" >/dev/null 2>/dev/null
346 # if test $? -eq 0; then ... whatever
348 # Additionally there is (since KDE 3.5.7) $KDE_SESSION_UID with the uid
349 # of the user running the KDE session. It should be rarely needed (e.g.
350 # after sudo to prevent desktop-wide functionality in the new user's kded).
352 # Since KDE4 there is also KDE_SESSION_VERSION, containing the major version number.
353 # Note that this didn't exist in KDE3, which can be detected by its absense and
354 # the presence of KDE_FULL_SESSION.
356 KDE_FULL_SESSION
=true
357 export KDE_FULL_SESSION
358 xprop
-root -f KDE_FULL_SESSION
8t
-set KDE_FULL_SESSION true
360 KDE_SESSION_VERSION
=4
361 export KDE_SESSION_VERSION
362 xprop
-root -f KDE_SESSION_VERSION
32c
-set KDE_SESSION_VERSION
4
365 export KDE_SESSION_UID
367 # We set LD_BIND_NOW to increase the efficiency of kdeinit.
368 # kdeinit unsets this variable before loading applications.
369 LD_BIND_NOW
=true kdeinit4
+kcminit_startup
370 if test $?
-ne 0; then
372 echo 'startkde: Could not start kdeinit4. Check your installation.' 1>&2
373 test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev
/null
374 xmessage
-geometry 500x100
"Could not start kdeinit4. Check your installation."
378 # If the session should be locked from the start (locked autologin),
379 # lock now and do the rest of the KDE startup underneath the locker.
380 if test -n "$dl"; then
381 kwrapper4 kscreenlocker
--forcelock &
382 # Give it some time for starting up. This is somewhat unclean; some
383 # notification would be better.
387 # finally, give the session control to the session manager
388 # see kdebase/ksmserver for the description of the rest of the startup sequence
389 # if the KDEWM environment variable has been set, then it will be used as KDE's
390 # window manager instead of kwin.
391 # if KDEWM is not set, ksmserver will ensure kwin is started.
392 # kwrapper4 is used to reduce startup time and memory usage
393 # kwrapper4 does not return useful error codes such as the exit code of ksmserver.
394 # We only check for 255 which means that the ksmserver process could not be
395 # started, any problems thereafter, e.g. ksmserver failing to initialize,
396 # will remain undetected.
397 test -n "$KDEWM" && KDEWM
="--windowmanager $KDEWM"
398 kwrapper4 ksmserver
$KDEWM
399 if test $?
-eq 255; then
401 echo 'startkde: Could not start ksmserver. Check your installation.' 1>&2
402 test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev
/null
403 xmessage
-geometry 500x100
"Could not start ksmserver. Check your installation."
406 # wait if there's any crashhandler shown
407 while qdbus |
grep "^[^w]*org.kde.drkonqi" > /dev
/null
; do
411 echo 'startkde: Shutting down...' 1>&2
413 test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev
/null
418 kde3 kdeinit_shutdown
2>/dev
/null
419 kde3 dcopserver_shutdown
--wait 2>/dev
/null
421 echo 'startkde: Running shutdown scripts...' 1>&2
423 # Run scripts found in $KDEDIRS/shutdown
424 for prefix
in `echo "$libpath" | sed -n -e 's,/lib[^/]*/,/shutdown/,p'`; do
425 for file in `ls "$prefix" 2> /dev/null | egrep -v '(~|\.bak)$'`; do
426 test -x "$prefix$file" && "$prefix$file"
430 unset KDE_FULL_SESSION
431 xprop
-root -remove KDE_FULL_SESSION
432 unset KDE_SESSION_VERSION
433 xprop
-root -remove KDE_SESSION_VERSION
434 unset KDE_SESSION_UID
436 echo 'startkde: Done.' 1>&2