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."
27 unset kcheckrunning_result
29 # Set the path for Katie plugins provided by KDE
30 QT_PLUGIN_PATH=${QT_PLUGIN_PATH+$QT_PLUGIN_PATH:}`kde4-config --path qtplugins`
33 # Set the platform plugin for Katie to the one provided by KDE
34 QT_PLATFORM_PLUGIN=kde
35 export QT_PLATFORM_PLUGIN
37 # Make sure that the KDE prefix is first in XDG_DATA_DIRS and that it's set at all.
38 # The spec allows XDG_DATA_DIRS to be not set, but X session startup scripts tend
39 # to set it to a list of paths *not* including the KDE prefix if it's not /usr or
41 if test -z "$XDG_DATA_DIRS"; then
42 XDG_DATA_DIRS="@KDE4_SHARE_INSTALL_PREFIX@:/usr/share:/usr/local/share"
44 XDG_DATA_DIRS="@KDE4_SHARE_INSTALL_PREFIX@:$XDG_DATA_DIRS"
50 # kdeinit is used to fork off processes which improves memory usage
53 # * kdeinit starts klauncher first.
54 # * Then kdeinit starts kcminit. kcminit performs initialisation of
55 # certain devices according to the user's settings
56 # * Then ksmserver is started which takes control of the rest of the startup sequence
58 # The user's personal KDE directory is usually ~/.kde, but this setting
59 # may be overridden by setting KDEHOME.
60 kdehome=$HOME/@KDE_DEFAULT_HOME@
61 test -n "$KDEHOME" && kdehome=`echo "$KDEHOME"|sed "s,^~/,$HOME/,"`
63 kcminputrc_mouse_cursortheme=`kreadconfig --file kcminputrc --group Mouse --key cursorTheme --default Oxygen_White`
64 kcminputrc_mouse_cursorsize=`kreadconfig --file kcminputrc --group Mouse --key cursorSize`
65 # XCursor mouse theme needs to be applied here to work even for kded or ksmserver
66 if test -n "$kcminputrc_mouse_cursortheme" -o -n "$kcminputrc_mouse_cursorsize" ; then
69 kapplymousetheme "$kcminputrc_mouse_cursortheme" "$kcminputrc_mouse_cursorsize"
70 if test -n "$kcminputrc_mouse_cursortheme"; then
71 XCURSOR_THEME="$kcminputrc_mouse_cursortheme"
74 if test -n "$kcminputrc_mouse_cursorsize"; then
75 XCURSOR_SIZE="$kcminputrc_mouse_cursorsize"
79 unset kcminputrc_mouse_cursortheme
80 unset kcminputrc_mouse_cursorsize
82 # Set a left cursor instead of the standard X11 "X" cursor, since I've heard
83 # from some users that they're confused and don't know what to do. This is
84 # especially necessary on slow machines, where starting KDE takes one or two
85 # minutes until anything appears on the screen.
87 # If the user has overwritten fonts, the cursor font may be different now
88 # so don't move this up.
89 xsetroot -cursor_name left_ptr
91 echo 'startkde: Starting up...' 1>&2
93 # in case we have been started with full pathname spec without being in PATH
94 if test -n "$PATH" ; then
95 qdbus=$(basename @QT_QDBUS_EXECUTABLE@)
97 qdbus=@QT_QDBUS_EXECUTABLE@
100 # Make sure that D-Bus is running
101 # D-Bus autolaunch is broken
102 if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
103 eval `dbus-launch --sh-syntax --exit-with-session`
105 if $qdbus >/dev/null 2>/dev/null; then
108 echo 'startkde: Could not start D-Bus. Can you call qdbus?' 1>&2
109 xmessage -geometry 500x100 "Could not start D-Bus. Can you call qdbus?"
114 # Mark that full KDE session is running. The KDE_FULL_SESSION property can be
115 # detected by any X client connected to the same X session, even if not
116 # launched directly from the KDE session but e.g. using "ssh -X", kdesudo.
117 # $KDE_FULL_SESSION however guarantees that the application is launched in the
118 # same environment like the KDE session and that e.g. KDE utilities/libraries
119 # are available. KDE_FULL_SESSION property is also only available since KDE
121 # The matching tests are:
122 # For $KDE_FULL_SESSION:
123 # if test -n "$KDE_FULL_SESSION"; then ... whatever
124 # For KDE_FULL_SESSION property:
125 # xprop -root | grep "^KDE_FULL_SESSION" >/dev/null 2>/dev/null
126 # if test $? -eq 0; then ... whatever
128 # Additionally there is (since KDE 3.5.7) $KDE_SESSION_UID with the uid
129 # of the user running the KDE session. It should be rarely needed (e.g.
130 # after sudo to prevent desktop-wide functionality in the new user's kded).
132 # Since KDE4 there is also KDE_SESSION_VERSION, containing the major version number.
133 # Note that this didn't exist in KDE3, which can be detected by its absense and
134 # the presence of KDE_FULL_SESSION.
135 KDE_FULL_SESSION=true
136 export KDE_FULL_SESSION
137 xprop -root -f KDE_FULL_SESSION 8t -set KDE_FULL_SESSION true
139 KDE_SESSION_VERSION=4
140 export KDE_SESSION_VERSION
141 xprop -root -f KDE_SESSION_VERSION 32c -set KDE_SESSION_VERSION 4
143 KDE_SESSION_UID=`id -ru`
144 export KDE_SESSION_UID
146 XDG_CURRENT_DESKTOP=KDE
147 export XDG_CURRENT_DESKTOP
149 # For session services that require X11, check for XDG_CURRENT_DESKTOP, etc.
150 dbus-update-activation-environment --all
152 # Start kdeinit4 + kcminit_startup
154 if test $? -ne 0; then
156 echo 'startkde: Could not start kdeinit4. Check your installation.' 1>&2
157 xmessage -geometry 500x100 "Could not start kdeinit4. Check your installation."
162 if test $? -ne 0; then
164 echo 'startkde: Could not start kcminit_startup. Check your installation.' 1>&2
165 xmessage -geometry 500x100 "Could not start kcminit_startup. Check your installation."
169 # finally, give the session control to the session manager
170 # see kdebase/ksmserver for the description of the rest of the startup sequence
171 # if the KDEWM environment variable has been set, then it will be used as KDE's
172 # window manager instead of kwin.
173 # if KDEWM is not set, ksmserver will ensure kwin is started.
174 test -n "$KDEWM" && KDEWM="--windowmanager $KDEWM"
176 if test $? -ne 0; then
178 echo 'startkde: Could not start ksmserver. Check your installation.' 1>&2
179 xmessage -geometry 500x100 "Could not start ksmserver. Check your installation."
182 wait_drkonqi=`kreadconfig --file startkderc --group WaitForDrKonqi --key Enabled --default true`
184 if test x"$wait_drkonqi"x = x"true"x ; then
185 # wait for remaining drkonqi instances with timeout (in seconds)
186 wait_drkonqi_timeout=`kreadconfig --file startkderc --group WaitForDrKonqi --key Timeout --default 900`
187 wait_drkonqi_counter=0
188 while $qdbus | grep "^[^w]*org.kde.drkonqi" > /dev/null ; do
190 wait_drkonqi_counter=$((wait_drkonqi_counter+5))
191 if test "$wait_drkonqi_counter" -ge "$wait_drkonqi_timeout" ; then
192 # ask remaining drkonqis to die in a graceful way
193 $qdbus | grep 'org.kde.drkonqi-' | while read address ; do
194 $qdbus "$address" "/MainApplication" "quit"
201 echo 'startkde: Shutting down...' 1>&2
206 unset KDE_FULL_SESSION
207 xprop -root -remove KDE_FULL_SESSION
208 unset KDE_SESSION_VERSION
209 xprop -root -remove KDE_SESSION_VERSION
210 unset KDE_SESSION_UID
212 echo 'startkde: Done.' 1>&2