fix what should not have been reverted in 3f2a38c725fc5da58e04129b93c7d320d139b82f
[opensuse:kdebase4-opensuse.git] / config-files / usr / share / kde4 / env / startkde.suse.sh
1 #!/bin/sh
2
3 desktop="`xdg-user-dir DESKTOP 2>/dev/null`"
4 if test -z "$desktop"; then
5     desktop=$HOME/Desktop
6 fi
7
8 #
9 # do we run in a prelinked system ?
10 #
11 if test -f /etc/sysconfig/prelink; then
12 . /etc/sysconfig/prelink
13   if test "$USE_PRELINK" = "yes" ; then
14      KDE_IS_PRELINKED=1
15      export KDE_IS_PRELINKED
16   else
17      unset KDE_IS_PRELINKED
18   fi
19 fi
20
21
22 # workaround SaX/SUSE bug that doesn't setup a proper keyboard map
23 #
24
25 if [ -f /usr/share/hotkey-setup/hotkey-setup.xmodmap ]; then
26   xmodmap /usr/share/hotkey-setup/hotkey-setup.xmodmap
27 fi
28
29 #
30 # Do we have a special Gtk theming for our Qt widget theme ?
31 #
32 if [ ! -e $HOME/.no-qtrc-to-gtkrc-mapping ]; then
33
34   SUSE_VERSION="`cat /etc/SuSE-release | sed -n 's/VERSION = //p'`"
35
36     # Defaults for openSUSE 10.3
37     GTK2_SYSCONFDIR=/etc
38     GTK2_DATADIR=/usr/share/themes/
39
40   # use general gtk-qt-engine
41   if [ -e "$GTK2_DATADIR/Qt/gtk-2.0/gtkrc" ] ; then
42     GTK2_THEME_RC="$GTK2_DATADIR/Qt/gtk-2.0/gtkrc"
43   else
44     # use QtCurve engine
45     if [ -e "$GTK2_DATADIR/QtCurve/gtk-2.0/gtkrc" ] ; then
46        GTK2_THEME_RC="$GTK2_DATADIR/QtCurve/gtk-2.0/gtkrc"
47     fi
48   fi
49
50   # GTK2
51   # NOTE: ~/.gtkrc-2.0-kde is added later (in latest KDE only)
52   if [ "$GTK2_RC_FILES" ]; then
53     export GTK2_RC_FILES="$GTK2_RC_FILES:$GTK2_THEME_RC:$HOME/.gtkrc-2.0-qtengine:$HOME/.gtkrc-2.0"
54   else
55     export GTK2_RC_FILES="$GTK2_SYSCONFDIR/gtk-2.0/gtkrc:$GTK2_THEME_RC:$HOME/.gtkrc-2.0-qtengine:$HOME/.gtkrc-2.0"
56   fi
57
58 fi
59
60 if [ -r /etc/sysconfig/windowmanager ]; then
61   # Do the user want the SuSE theme ?
62   source /etc/sysconfig/windowmanager
63
64   # Should we really enable FAM support for KDE ?
65   export USE_FAM="$KDE_USE_FAM"
66
67   # Disable IPv6 ?
68   if [ "$KDE_USE_IPV6" = "no" ]; then
69      export KDE_NO_IPV6=1
70   fi
71   # Disable IDN ?
72   if [ "$KDE_USE_IDN" = "no" ]; then
73      export KDE_NO_IDN=1
74   fi
75
76 else
77   if [ -r /etc/rc.config ]; then
78     # Do the user want the SuSE theme ?
79     INSTALL_DESKTOP_EXTENSIONS=`bash -c "source /etc/rc.config && echo \\$INSTALL_DESKTOP_EXTENSIONS"`
80
81     # Should we really enable FAM support for KDE ?
82     USE_FAM=`bash -c "source /etc/rc.config && echo \\$KDE_USE_FAM"`
83     export USE_FAM
84   fi
85 fi
86
87 #
88 # create SuSE defaults
89 #
90 if [ ! -e "$HOME/.skel/kdebase4.120" ]; then
91     mkdir -p "$desktop"
92
93     if [ -e "/usr/bin/firefox" -a ! -e "$desktop/MozillaFirefox.desktop" -a -e "/usr/share/kde4/config/SuSE/default/MozillaFirefox.desktop" ]; then
94           cp /usr/share/kde4/config/SuSE/default/MozillaFirefox.desktop "$desktop/"
95     fi
96     chmod u+x "$desktop/MozillaFirefox.desktop" 2>/dev/null
97
98     if [ -e "/usr/bin/oofromtemplate" -a  ! -e "$desktop/Office.desktop" -a -e "/usr/share/kde4/config/SuSE/default/Office.desktop" ]; then
99           cp /usr/share/kde4/config/SuSE/default/Office.desktop "$desktop/"
100     fi
101     chmod u+x "$desktop/Office.desktop" 2>/dev/null
102
103     if [ ! -e "$desktop/SuSE.desktop" -a -e "/usr/share/kde4/config/SuSE/default/SuSE.desktop" ]; then
104           cp /usr/share/kde4/config/SuSE/default/SuSE.desktop "$desktop/"
105     fi
106     chmod u+x "$desktop/SuSE.desktop" 2>/dev/null
107
108     if [ ! -e "$desktop/Support.desktop" -a -e "/usr/share/kde4/config/SuSE/default/Support.desktop" ]; then
109           cp /usr/share/kde4/config/SuSE/default/Support.desktop "$desktop/"
110     fi
111     sed -i 's/^Icon=susehelpcenter$/Icon=Support/' "$desktop/Support.desktop"
112     chmod u+x "$desktop/Support.desktop" 2>/dev/null
113
114     if [ ! -e "$desktop/myComputer.desktop" -a -e "/usr/share/kde4/config/SuSE/default/myComputer.desktop" ]; then
115           cp /usr/share/kde4/config/SuSE/default/myComputer.desktop "$desktop/"
116     fi
117     chmod u+x "$desktop/myComputer.desktop" 2>/dev/null
118
119     if [ ! -e $HOME/.kde4/share/config/kdeglobals -a -e /usr/share/kde4/config/SuSE/default/kdeglobals ]; then
120           mkdir -p $HOME/.kde4/share/config
121           cp /usr/share/kde4/config/SuSE/default/kdeglobals $HOME/.kde4/share/config/kdeglobals
122           # add Language= and Country=
123           local=`/usr/bin/locale 2>&1 | grep LC_MESSAGES | sed -e 's#^LC_MESSAGES="\(.*\)"$#\1#; s#\..*##'`
124           lang=`echo $local | sed -e 's,_.*$,,'`
125           countr=`echo $local | sed -e 's,^.*_,,' | tr 'A-Z' 'a-z'`
126           if test -z "$countr"; then countr=$lang; fi
127           cat >>$HOME/.kde4/share/config/kdeglobals <<EOF
128 [Locale]
129 Country=$countr
130 Language=$lang
131 EOF
132     fi
133
134     if [ ! -e $HOME/.kde4/share/config/kcminputrc -a -e /usr/share/kde4/config/SuSE/default/kcminputrc ]; then
135           mkdir -p $HOME/.kde4/share/config
136           cp /usr/share/kde4/config/SuSE/default/kcminputrc $HOME/.kde4/share/config/kcminputrc
137     fi
138
139     if [ ! -e $HOME/.kde4/share/config/nepomukserverrc -a -e /usr/share/kde4/config/SuSE/default/nepomukserverrc ]; then
140           mkdir -p $HOME/.kde4/share/config
141           cp /usr/share/kde4/config/SuSE/default/nepomukserverrc $HOME/.kde4/share/config/nepomukserverrc
142     fi
143
144     if [ ! -e "$HOME/.kde4/share/apps/konqueror/bookmarks.xml" -a -e "/usr/share/kde4/config/SuSE/default/bookmarks.xml" ]; then
145           mkdir -p $HOME/.kde4/share/apps/konqueror
146           cp /usr/share/kde4/config/SuSE/default/bookmarks.xml $HOME/.kde4/share/apps/konqueror/bookmarks.xml
147     fi
148
149     if [ ! -e "$HOME/.kde4/share/apps/akregator/data/feeds.opml" -a -e "/usr/share/kde4/config/SuSE/default/feeds.opml" ]; then
150           mkdir -p $HOME/.kde4/share/apps/akregator/data
151           cp /usr/share/kde4/config/SuSE/default/feeds.opml $HOME/.kde4/share/apps/akregator/data/feeds.opml
152     fi
153
154     documents="`xdg-user-dir DOCUMENTS 2>/dev/null`"
155     if test -z "$documents"; then
156         documents=$HOME/Documents
157     fi
158     mkdir -p "$documents"
159     if [ ! -e "$documents/.directory" -a -e "/usr/share/kde4/config/SuSE/default/documents.directory" ]; then
160           cp /usr/share/kde4/config/SuSE/default/documents.directory "$documents/.directory"
161     fi
162
163     mkdir -p $HOME/.skel/
164     touch $HOME/.skel/kdebase4.120
165 fi
166
167 # check if any rpms have been (un)installed since ksycoca
168 # had been built, if yes, trigger ksycoca rebuild immediatelly
169 # instead of delayed
170
171 kdehome=$HOME/.kde4
172 test -n "$KDEHOME" && kdehome=`echo "$KDEHOME"|sed "s,^~/,$HOME/,"`
173 host=$HOSTNAME
174 test -n "$XAUTHLOCALHOSTNAME" && host=$XAUTHLOCALHOSTNAME
175 ksycoca="$kdehome/cache-$host/ksycoca"
176
177 if test -f "$ksycoca"; then
178     if test -f /var/lib/rpm/Packages; then
179         if test /var/lib/rpm/Packages -nt "$ksycoca"; then
180             rm -f "$ksycoca"
181         fi
182     fi
183 fi