OSDN Git Service

kdirshare: update comment related to kpasswdstore service
[kde/kde-workspace.git] / startkde.cmake
1 #!/bin/sh
2 #
3 #  DEFAULT KDE STARTUP SCRIPT ( @KDE_VERSION_STRING@ )
4 #
5
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
10 fi
11
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
15
16 # Check if a KDE session already is running and whether it's possible to connect to X
17 kcheckrunning
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
22     exit 1
23 elif test $kcheckrunning_result -eq 2 ; then
24     echo "\$DISPLAY is not set or cannot connect to the X server."
25     exit 1
26 fi
27 unset kcheckrunning_result
28
29 # Set the path for Katie plugins provided by KDE
30 QT_PLUGIN_PATH=${QT_PLUGIN_PATH+$QT_PLUGIN_PATH:}`kde4-config --path qtplugins`
31 export QT_PLUGIN_PATH
32
33 # Set the platform plugin for Katie to the one provided by KDE
34 QT_PLATFORM_PLUGIN=kde
35 export QT_PLATFORM_PLUGIN
36
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
40 # /usr/local.
41 if test -z "$XDG_DATA_DIRS"; then
42     XDG_DATA_DIRS="@KDE4_SHARE_INSTALL_PREFIX@:/usr/share:/usr/local/share"
43 else
44     XDG_DATA_DIRS="@KDE4_SHARE_INSTALL_PREFIX@:$XDG_DATA_DIRS"
45 fi
46 export XDG_DATA_DIRS
47
48 # Boot sequence:
49 #
50 # kdeinit is used to fork off processes which improves memory usage
51 # and startup time.
52 #
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
57
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/,"`
62
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
67     @EXPORT_XCURSOR_PATH@
68
69     kapplymousetheme "$kcminputrc_mouse_cursortheme" "$kcminputrc_mouse_cursorsize"
70     if test -n "$kcminputrc_mouse_cursortheme"; then
71         XCURSOR_THEME="$kcminputrc_mouse_cursortheme"
72         export XCURSOR_THEME
73     fi
74     if test -n "$kcminputrc_mouse_cursorsize"; then
75         XCURSOR_SIZE="$kcminputrc_mouse_cursorsize"
76         export XCURSOR_SIZE
77     fi
78 fi
79 unset kcminputrc_mouse_cursortheme
80 unset kcminputrc_mouse_cursorsize
81
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.
86 #
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
90
91 echo 'startkde: Starting up...'  1>&2
92
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@)
96 else
97     qdbus=@QT_QDBUS_EXECUTABLE@
98 fi
99
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`
104 fi
105 if $qdbus >/dev/null 2>/dev/null; then
106     : # ok
107 else
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?"
110     exit 1
111 fi
112
113
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
120 # 3.5.5.
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
127 #
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).
131 #
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
138
139 KDE_SESSION_VERSION=4
140 export KDE_SESSION_VERSION
141 xprop -root -f KDE_SESSION_VERSION 32c -set KDE_SESSION_VERSION 4
142
143 KDE_SESSION_UID=`id -ru`
144 export KDE_SESSION_UID
145
146 XDG_CURRENT_DESKTOP=KDE
147 export XDG_CURRENT_DESKTOP
148
149 # For session services that require X11, check for XDG_CURRENT_DESKTOP, etc.
150 dbus-update-activation-environment --all
151
152 # Start kdeinit4 + kcminit_startup
153 kdeinit4
154 if test $? -ne 0; then
155     # Startup error
156     echo 'startkde: Could not start kdeinit4. Check your installation.'  1>&2
157     xmessage -geometry 500x100 "Could not start kdeinit4. Check your installation."
158     exit 1
159 fi
160
161 kcminit_startup
162 if test $? -ne 0; then
163     # Startup error
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."
166     exit 1
167 fi
168
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"
175 ksmserver $KDEWM
176 if test $? -ne 0; then
177     # Startup error
178     echo 'startkde: Could not start ksmserver. Check your installation.'  1>&2
179     xmessage -geometry 500x100 "Could not start ksmserver. Check your installation."
180 fi
181
182 wait_drkonqi=`kreadconfig --file startkderc --group WaitForDrKonqi --key Enabled --default true`
183
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
189         sleep 5
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"
195             done
196             break
197         fi
198     done
199 fi
200
201 echo 'startkde: Shutting down...'  1>&2
202
203 # Clean up
204 kdeinit4 --shutdown
205
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
211
212 echo 'startkde: Done.'  1>&2