Add (and install) svg for the new krunner interface.
[kdebase/uwolfer.git] / workspace / startkde.cmake
blob7eec075758ebe4f579d8e5398235b2bb5bf4dd4b
1 #!/bin/sh
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
11 kcheckrunning
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
16 exit 1
17 elif test $kcheckrunning_result -eq 2 ; then
18 echo "\$DISPLAY is not set or cannot connect to the X server."
19 exit 1
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
34 MALLOC_CHECK_=2
35 export MALLOC_CHECK_
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 case $PATH in
41 $bindir|$bindir:*|*:$bindir|*:$bindir:*) ;;
42 *) PATH=$bindir:$PATH; export PATH;;
43 esac
46 # Boot sequence:
48 # kdeinit is used to fork off processes which improves memory usage
49 # and startup time.
51 # * kdeinit starts klauncher first.
52 # * Then kded is started. kded is responsible for keeping the sycoca
53 # database up to date. When an up to date database is present it goes
54 # into the background and the startup continues.
55 # * Then kdeinit starts kcminit. kcminit performs initialisation of
56 # certain devices according to the user's settings
58 # * Then ksmserver is started which takes control of the rest of the startup sequence
60 # The user's personal KDE directory is usually ~/.kde, but this setting
61 # may be overridden by setting KDEHOME.
63 kdehome=$HOME/.kde
64 test -n "$KDEHOME" && kdehome=`echo "$KDEHOME"|sed "s,^~/,$HOME/,"`
66 # see kstartupconfig source for usage
67 mkdir -m 700 -p $kdehome
68 mkdir -m 700 -p $kdehome/share
69 mkdir -m 700 -p $kdehome/share/config
70 cat >$kdehome/share/config/startupconfigkeys <<EOF
71 kcminputrc Mouse cursorTheme ''
72 kcminputrc Mouse cursorSize ''
73 ksplashrc KSplash Theme Default
74 ksplashrc KSplash Engine KSplashX
75 kcmrandrrc Display ApplyOnStartup false
76 kcmrandrrc [Screen0]
77 kcmrandrrc [Screen1]
78 kcmrandrrc [Screen2]
79 kcmrandrrc [Screen3]
80 kcmfonts General forceFontDPI 0
81 EOF
82 kstartupconfig4
83 if test $? -ne 0; then
84 xmessage -geometry 500x100 "Could not start kstartupconfig4. Check your installation."
85 exit 1
87 [ -r $kdehome/share/config/startupconfig ] && . $kdehome/share/config/startupconfig
89 # XCursor mouse theme needs to be applied here to work even for kded or ksmserver
90 if test -n "$kcminputrc_mouse_cursortheme" -o -n "$kcminputrc_mouse_cursorsize" ; then
91 kapplymousetheme "$kcminputrc_mouse_cursortheme" "$kcminputrc_mouse_cursorsize"
92 if test $? -eq 10; then
93 export XCURSOR_THEME=default
94 elif test -n "$kcminputrc_mouse_cursortheme"; then
95 export XCURSOR_THEME="$kcminputrc_mouse_cursortheme"
97 if test -n "$kcminputrc_mouse_cursorsize"; then
98 export XCURSOR_SIZE="$kcminputrc_mouse_cursorsize"
102 if test "$kcmrandrrc_display_applyonstartup" = "true"; then
103 # 4 screens is hopefully enough
104 for scrn in 0 1 2 3; do
105 args=
106 width="\$kcmrandrrc_screen${scrn}_width" ; eval "width=$width"
107 height="\$kcmrandrrc_screen${scrn}_height" ; eval "height=$height"
108 if test -n "${width}" -a -n "${height}"; then
109 args="$args -s ${width}x${height}"
111 refresh="\$kcmrandrrc_screen${scrn}_refresh" ; eval "refresh=$refresh"
112 if test -n "${refresh}"; then
113 args="$args -r ${refresh}"
115 rotation="\$kcmrandrrc_screen${scrn}_rotation" ; eval "rotation=$rotation"
116 if test -n "${rotation}"; then
117 case "${rotation}" in
119 args="$args -o 0"
122 args="$args -o 1"
124 180)
125 args="$args -o 2"
127 270)
128 args="$args -o 3"
130 esac
132 reflectx="\$kcmrandrrc_screen${scrn}_reflectx" ; eval "reflectx=$reflectx"
133 if test "${refrectx}" = "true"; then
134 args="$args -x"
136 reflecty="\$kcmrandrrc_screen${scrn}_reflecty" ; eval "reflecty=$reflecty"
137 if test "${refrecty}" = "true"; then
138 args="$args -y"
140 if test -n "$args"; then
141 xrandr $args
143 done
146 if test "$kcmfonts_general_forcefontdpi" -eq 120; then
147 xrdb -quiet -merge -nocpp <<EOF
148 Xft.dpi: 120
150 elif test "$kcmfonts_general_forcefontdpi" -eq 96; then
151 xrdb -quiet -merge -nocpp <<EOF
152 Xft.dpi: 96
157 dl=$DESKTOP_LOCKED
158 unset DESKTOP_LOCKED # Don't want it in the environment
160 ksplash_pid=
161 if test -z "$dl"; then
162 # the splashscreen and progress indicator
163 case "$ksplashrc_ksplash_engine" in
164 KSplashX)
165 ksplash_pid=`ksplashx ${ksplashrc_ksplash_theme} --pid`
167 None)
169 Simple)
170 ksplash_pid=`ksplashsimple ${ksplashrc_ksplash_theme} --pid`
174 esac
177 # Source scripts found in <localprefix>/env/*.sh and <prefixes>/env/*.sh
178 # (where <localprefix> is $KDEHOME or ~/.kde, and <prefixes> is where KDE is installed)
180 # This is where you can define environment variables that will be available to
181 # all KDE programs, so this is where you can run agents using e.g. eval `ssh-agent`
182 # or eval `gpg-agent --daemon`.
183 # Note: if you do that, you should also put "ssh-agent -k" as a shutdown script
185 # (see end of this file).
186 # For anything else (that doesn't set env vars, or that needs a window manager),
187 # better use the Autostart folder.
189 libpath=`kde4-config --path lib | tr : '\n'`
191 for prefix in `echo "$libpath" | sed -n -e 's,/lib[^/]*/,/env/,p'`; do
192 for file in "$prefix"*.sh; do
193 test -r "$file" && . "$file"
194 done
195 done
197 # Set the path for Qt plugins provided by KDE
198 if test -n "$QT_PLUGIN_PATH"; then
199 QT_PLUGIN_PATH="$QT_PLUGIN_PATH:`kde4-config --path qtplugins`"
200 else
201 QT_PLUGIN_PATH="`kde4-config --path qtplugins`"
203 export QT_PLUGIN_PATH
205 # Activate the kde font directories.
207 # There are 4 directories that may be used for supplying fonts for KDE.
209 # There are two system directories. These belong to the administrator.
210 # There are two user directories, where the user may add her own fonts.
212 # The 'override' versions are for fonts that should come first in the list,
213 # i.e. if you have a font in your 'override' directory, it will be used in
214 # preference to any other.
216 # The preference order looks like this:
217 # user override, system override, X, user, system
219 # Where X is the original font database that was set up before this script
220 # runs.
222 usr_odir=$HOME/.fonts/kde-override
223 usr_fdir=$HOME/.fonts
225 if test -n "$KDEDIRS"; then
226 kdedirs_first=`echo "$KDEDIRS"|sed -e 's/:.*//'`
227 sys_odir=$kdedirs_first/share/fonts/override
228 sys_fdir=$kdedirs_first/share/fonts
229 else
230 sys_odir=$KDEDIR/share/fonts/override
231 sys_fdir=$KDEDIR/share/fonts
234 # We run mkfontdir on the user's font dirs (if we have permission) to pick
235 # up any new fonts they may have installed. If mkfontdir fails, we still
236 # add the user's dirs to the font path, as they might simply have been made
237 # read-only by the administrator, for whatever reason.
239 test -d "$sys_odir" && xset +fp "$sys_odir"
240 test -d "$usr_odir" && (mkfontdir "$usr_odir" ; xset +fp "$usr_odir")
241 test -d "$usr_fdir" && (mkfontdir "$usr_fdir" ; xset fp+ "$usr_fdir")
242 test -d "$sys_fdir" && xset fp+ "$sys_fdir"
244 # Ask X11 to rebuild its font list.
245 xset fp rehash
247 # Set a left cursor instead of the standard X11 "X" cursor, since I've heard
248 # from some users that they're confused and don't know what to do. This is
249 # especially necessary on slow machines, where starting KDE takes one or two
250 # minutes until anything appears on the screen.
252 # If the user has overwritten fonts, the cursor font may be different now
253 # so don't move this up.
255 xsetroot -cursor_name left_ptr
257 # Get Ghostscript to look into user's KDE fonts dir for additional Fontmap
258 if test -n "$GS_LIB" ; then
259 GS_LIB=$usr_fdir:$GS_LIB
260 export GS_LIB
261 else
262 GS_LIB=$usr_fdir
263 export GS_LIB
266 lnusertemp=`kde4-config --path exe --locate lnusertemp`
267 if test -z "$lnusertemp"; then
268 # Startup error
269 echo 'startkde: ERROR: Could not locate lnusertemp in '`kde4-config --path exe` 1>&2
272 # Link "tmp" "socket" and "cache" resources to directory in /tmp
273 # Creates:
274 # - a directory /tmp/kde-$USER and links $KDEHOME/tmp-$HOSTNAME to it.
275 # - a directory /tmp/ksocket-$USER and links $KDEHOME/socket-$HOSTNAME to it.
276 # - a directory /var/tmp/kdecache-$USER and links $KDEHOME/cache-$HOSTNAME to it.
277 # Note: temporary locations can be overriden through the KDETMP and KDEVARTMP
278 # environment variables
279 for resource in tmp cache socket; do
280 if ! "$lnusertemp" $resource >/dev/null; then
281 echo 'startkde: Call to lnusertemp failed (temporary directories full?). Check your installation.' 1>&2
282 test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null
283 xmessage -geometry 600x100 "Call to lnusertemp failed (temporary directories full?). Check your installation."
284 exit 1
286 done
288 # In case of dcop sockets left by a previous session, cleanup
289 #dcopserver_shutdown
291 echo 'startkde: Starting up...' 1>&2
293 # Make sure that D-Bus is running
294 if test -z "$XDG_DATA_DIRS"; then
295 XDG_DATA_DIRS="`kde4-config --prefix`/share:/usr/share:/usr/local/share"
296 export XDG_DATA_DIRS
298 # D-Bus autolaunch is broken
299 if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
300 eval `dbus-launch --sh-syntax --exit-with-session`
302 if qdbus >/dev/null 2>/dev/null; then
303 : # ok
304 else
305 echo 'startkde: Could not start D-Bus. Check your installation.' 1>&2
306 test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null
307 xmessage -geometry 500x100 "Could not start D-Bus. Check your installation."
308 exit 1
312 # Mark that full KDE session is running (e.g. Konqueror preloading works only
313 # with full KDE running). The KDE_FULL_SESSION property can be detected by
314 # any X client connected to the same X session, even if not launched
315 # directly from the KDE session but e.g. using "ssh -X", kdesu. $KDE_FULL_SESSION
316 # however guarantees that the application is launched in the same environment
317 # like the KDE session and that e.g. KDE utilities/libraries are available.
318 # KDE_FULL_SESSION property is also only available since KDE 3.5.5.
319 # The matching tests are:
320 # For $KDE_FULL_SESSION:
321 # if test -n "$KDE_FULL_SESSION"; then ... whatever
322 # For KDE_FULL_SESSION property:
323 # xprop -root | grep "^KDE_FULL_SESSION" >/dev/null 2>/dev/null
324 # if test $? -eq 0; then ... whatever
326 # Additionally there is (since KDE 3.5.7) $KDE_SESSION_UID with the uid
327 # of the user running the KDE session. It should be rarely needed (e.g.
328 # after sudo to prevent desktop-wide functionality in the new user's kded).
330 KDE_FULL_SESSION=true
331 export KDE_FULL_SESSION
332 xprop -root -f KDE_FULL_SESSION 8t -set KDE_FULL_SESSION true
334 KDE_SESSION_VERSION=4
335 export KDE_SESSION_VERSION
336 xprop -root -f KDE_SESSION_VERSION 32c -set KDE_SESSION_VERSION 4
338 KDE_SESSION_UID=$UID
339 export KDE_SESSION_UID
341 # We set LD_BIND_NOW to increase the efficiency of kdeinit.
342 # kdeinit unsets this variable before loading applications.
343 LD_BIND_NOW=true kdeinit4 +kcminit_startup
344 if test $? -ne 0; then
345 # Startup error
346 echo 'startkde: Could not start kdeinit4. Check your installation.' 1>&2
347 test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null
348 xmessage -geometry 500x100 "Could not start kdeinit4. Check your installation."
349 exit 1
352 # If the session should be locked from the start (locked autologin),
353 # lock now and do the rest of the KDE startup underneath the locker.
354 if test -n "$dl"; then
355 kwrapper4 krunner_lock --forcelock &
356 # Give it some time for starting up. This is somewhat unclean; some
357 # notification would be better.
358 sleep 1
361 # finally, give the session control to the session manager
362 # see kdebase/ksmserver for the description of the rest of the startup sequence
363 # if the KDEWM environment variable has been set, then it will be used as KDE's
364 # window manager instead of kwin.
365 # if KDEWM is not set, ksmserver will ensure kwin is started.
366 # kwrapper4 is used to reduce startup time and memory usage
367 # kwrapper4 does not return useful error codes such as the exit code of ksmserver.
368 # We only check for 255 which means that the ksmserver process could not be
369 # started, any problems thereafter, e.g. ksmserver failing to initialize,
370 # will remain undetected.
371 test -n "$KDEWM" && KDEWM="--windowmanager $KDEWM"
372 kwrapper4 ksmserver $KDEWM
373 if test $? -eq 255; then
374 # Startup error
375 echo 'startkde: Could not start ksmserver. Check your installation.' 1>&2
376 test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null
377 xmessage -geometry 500x100 "Could not start ksmserver. Check your installation."
380 # wait if there's any crashhandler shown
381 while qdbus | grep "^[^w]*org.kde.drkonqi" > /dev/null ; do
382 sleep 5
383 done
385 echo 'startkde: Shutting down...' 1>&2
386 # just in case
387 test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null
389 # Clean up
390 kdeinit4_shutdown
392 echo 'startkde: Running shutdown scripts...' 1>&2
394 # Run scripts found in $KDEDIRS/shutdown
395 for prefix in `echo "$libpath" | sed -n -e 's,/lib[^/]*/,/shutdown/,p'`; do
396 for file in `ls "$prefix" 2> /dev/null | egrep -v '(~|\.bak)$'`; do
397 test -x "$prefix$file" && "$prefix$file"
398 done
399 done
401 unset KDE_FULL_SESSION
402 xprop -root -remove KDE_FULL_SESSION
403 unset KDE_SESSION_VERSION
404 xprop -root -remove KDE_SESSION_VERSION
405 unset KDE_SESSION_UID
407 echo 'startkde: Done.' 1>&2