TDE base libraries and programs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

starttde 28KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  1. #!/bin/sh
  2. #
  3. # DEFAULT TRINITY STARTUP SCRIPT
  4. #
  5. # This block might not be appropriate for all systems.
  6. # It should work for command line logins but graphical
  7. # login managers might already source these files.
  8. # Multiple sourcing is not a problem when the files are only
  9. # containers for environment variables and such.
  10. if [ -r /etc/xprofile ]; then
  11. source /etc/xprofile
  12. fi
  13. if [ -r $HOME/.xprofile ]; then
  14. source $HOME/.xprofile
  15. fi
  16. # Some functions to parse and check path correctly ...
  17. # Usage: is_in_path PATH /usr/bin
  18. is_in_path() {
  19. var="$1"; search="$2";
  20. if eval test -z \$$1; then return 1; fi
  21. ifs="$IFS"; IFS=":"; eval set \$$var; IFS="$ifs"
  22. for i in $*; do
  23. [ "${i}" = "${search}" ] && return 0
  24. done
  25. return 1
  26. }
  27. # Usage: is_before_in_path ENV_VAR var before_var
  28. # Return 0 if 'var' is before 'before_var' in 'ENV_VAR', 1 otherwise
  29. is_before_in_path() {
  30. [ $# -ge 3 ] || return 1
  31. var="$1"; search="$2"; before="$3"
  32. ifs="$IFS"; IFS=":"; eval set \$$var; IFS="$ifs"
  33. for i in $*; do
  34. [ "${i}" = "${search}" ] && return 0
  35. [ "${i}" = "${before}" ] && return 1
  36. done
  37. return 1
  38. }
  39. # Usage: place_before_in_path PATH /opt/trinity/games /usr/games
  40. place_before_in_path() {
  41. var="$1"; insert="$2";
  42. if eval test -z \$$1; then
  43. eval export $var=${insert}
  44. else
  45. before="$3"; ifs="$IFS"; IFS=":"; eval set \$$var; IFS="$ifs"
  46. NPATH=""
  47. for i in $*; do
  48. [ "${i}" = "${before}" ] && NPATH="${NPATH}:${insert}"
  49. NPATH="${NPATH}:${i}"
  50. done
  51. eval export $var=${NPATH#:}
  52. fi
  53. }
  54. # Usage: remove_from_path PATH /opt/trinity/games
  55. remove_from_path() {
  56. var="$1"; remove="$2";
  57. if eval test -z \$$1; then return 1; fi
  58. ifs="$IFS"; IFS=":"; eval set \$$var; IFS="$ifs"
  59. NPATH=""
  60. for i in $*; do
  61. [ "${i}" != "${remove}" ] && NPATH="${NPATH}:${i}"
  62. done
  63. eval export $var=${NPATH#:}
  64. }
  65. echo "[starttde] Starting starttde." 1>&2
  66. echo "[starttde] This script is $0" 1>&2
  67. # Avoid any possible conflict with KDE4. Therefore within this script
  68. # use full path names to all binaries used.
  69. # The binaries for TDE are located in the same place as this script.
  70. # To determine that location use the following method rather than presuming
  71. # the existence of $TDEDIR. That environment variable might not be
  72. # defined or defined to point to KDE4 binaries.
  73. BIN_DIR="`dirname \`readlink -f $0\``"
  74. if [ -x $BIN_DIR/tde-config ]; then
  75. TDE_VERSION=$($BIN_DIR/tde-config --version | while IFS=: read a b; do [ "${a#TDE}" != "$a" ] && echo $b; done)
  76. echo "[starttde] TDE version is $TDE_VERSION" 1>&2
  77. export TDEDIR=${BIN_DIR%/bin}
  78. echo "[starttde] TDE base directory is $TDEDIR" 1>&2
  79. else
  80. echo "[starttde] Unable to determine the TDE bin directory, where this script should be installed."
  81. echo "[starttde] This script should be installed in the same directory."
  82. echo "[starttde] Exiting."
  83. exit 1
  84. fi
  85. unset BIN_DIR
  86. # When the X server dies we get a HUP signal from xinit. We must ignore it
  87. # because we still need to do some cleanup.
  88. trap 'echo "[starttde] GOT SIGHUP"' HUP
  89. # Check if a TDE session is already running.
  90. if kcheckrunning >/dev/null 2>&1; then
  91. echo "[starttde] TDE seems to be already running on this display."
  92. xmessage -center -geometry 500x100 "TDE seems to be already running on this display." > /dev/null 2>/dev/null
  93. exit 1
  94. fi
  95. # Set the background color.
  96. # The standard X background is nasty, causing moire effects and exploding
  97. # people's heads. We use colours from the standard TDE palette for those with
  98. # palettised displays.
  99. if test -z "$XDM_MANAGED" || echo "$XDM_MANAGED" | grep ",auto" > /dev/null; then
  100. xsetroot -solid "#618DCC" # sky blue
  101. fi
  102. # Unset this for Darwin since it will screw up TDE's dynamic-loading.
  103. unset DYLD_FORCE_FLAT_NAMESPACE
  104. # Check whether prelinking is enabled. If yes, then exporting TDE_IS_PRELINKED improves
  105. # loading TDE. The $TDE_IS_PRELINKED variable might already be set on some systems
  106. # through /etc/profile.d. Therefore first check whether the variable exists.
  107. if [ "$TDE_IS_PRELINKED" = "" ]; then
  108. if [ -r /etc/default/prelink ]; then
  109. . /etc/default/prelink
  110. elif [ -r /etc/sysconfig/prelink ]; then
  111. . /etc/sysconfig/prelink
  112. fi
  113. if [ "$PRELINKING" = "yes" ]; then
  114. export TDE_IS_PRELINKED=1
  115. fi
  116. fi
  117. # Boot sequence:
  118. #
  119. # tdeinit is used to fork off processes which improves memory usage
  120. # and startup time.
  121. #
  122. # * tdeinit starts the dcopserver and tdelauncher first.
  123. # * Then kded is started. kded is responsible for keeping the sycoca
  124. # database up to date. When an up to date database is present it goes
  125. # into the background and the startup continues.
  126. # * Then tdeinit starts kcminit. kcminit performs initialisation of
  127. # certain devices according to the user's settings
  128. #
  129. # * Then ksmserver is started which takes control of the rest of the startup sequence.
  130. # The user's personal TDE directory usually is $HOME/.trinity.
  131. # This setting may be overridden by setting $TDEHOME. When migrating profiles
  132. # must be careful here because $HOME/.kde was used commonly in the pre-KDE4
  133. # days for the user's TDE profile, but now with KDE4 common on systems,
  134. # $HOME/.kde might point to KDE4 profile settings. The existence of KDE4
  135. # does not mean all people are using KDE4.
  136. if [ "$TDEHOME" != "" ]; then
  137. echo "[starttde] TDEHOME is preset to $TDEHOME." 1>&2
  138. export TDEHOME=$TDEHOME
  139. else
  140. # $TDEHOME is NOT already preset in the environment. Try to help.
  141. # This might be overkill but does provide flexibility.
  142. # This script and kstandardirs.h and kstandardirs.cpp must match.
  143. # The latter two must be edited/patched before compiling.
  144. echo "[starttde] TDEHOME is not set." 1>&2
  145. # Default value: $HOME/.trinity. Most users will use this.
  146. export TDEHOME=$HOME/.trinity
  147. if [ ! -d $HOME/.trinity ] && [ ! -f /usr/bin/kde4-config ] && [ "$TDEDIR"="/usr" ] && [ -d $HOME/.kde ]; then
  148. # Looks like Trinity is installed and not playing second fiddle to KDE4.
  149. export TDEHOME=$HOME/.kde
  150. fi
  151. echo "[starttde] Set TDEHOME to $TDEHOME." 1>&2
  152. fi
  153. # tdesu needs something to find root's TDE profile. Set the TDEROOTHOME variable
  154. # here as last resort. /root/.trinity is a safe presumption. If an admin wants
  155. # a different location then set the TDEROOTHOME variable elsewhere.
  156. if [ "$TDEROOTHOME" = "" ]; then
  157. export TDEROOTHOME=/root/.trinity
  158. echo "[starttde] Setting TDEROOTHOME to $TDEROOTHOME."
  159. fi
  160. # Modify the following environment variables only as necessary.
  161. if ! is_in_path PATH "$TDEDIR/games" ; then
  162. # Respect the traditional path order. Don't blindly place $TDEDIR/games
  163. # first in the path. Only place $TDEDIR/games before /usr/games. If packagers
  164. # are adding $TDEDIR/games elsewhere, then they need to ensure the traditional
  165. # search patch is respected.
  166. # Is there a way we can check that $TDEDIR/games is always placed only just before
  167. # /usr/games in the search path?
  168. if is_in_path PATH "/usr/games"; then
  169. place_before_in_path PATH "$TDEDIR/games" "/usr/games"
  170. else
  171. export PATH=$TDEDIR/games:$PATH
  172. fi
  173. fi
  174. if ! is_in_path PATH "$TDEDIR/bin" ]; then
  175. # Respect the traditional path order. Don't blindly place $TDEDIR/bin
  176. # first in the path. Only place $TDEDIR/bin before /usr/bin. This order is
  177. # consistent with tdelibs/tdesu/stub.cpp. If packagers are adding $TDEDIR/bin
  178. # elsewhere, then they need to ensure the traditional search patch is respected.
  179. # Is there a way we can check that $TDEDIR/bin is always placed only just before
  180. # /usr/bin in the search path?
  181. if is_in_path PATH "/usr/bin"; then
  182. place_before_in_path PATH "$TDEDIR/bin" "/usr/bin"
  183. else
  184. export PATH=$TDEDIR/bin:$PATH
  185. fi
  186. fi
  187. if [ -x /usr/bin/manpath ]; then
  188. if [ "`manpath 2>/dev/null | grep \"$TDEDIR/share/man\"`" = "" ]; then
  189. export MANPATH=$TDEDIR/share/man:$MANPATH
  190. fi
  191. else
  192. if [ "`echo $MANPATH | grep \"$TDEDIR/share/man\"`" = "" ]; then
  193. export MANPATH=$TDEDIR/share/man:$MANPATH
  194. fi
  195. fi
  196. if [ "$XDG_CONFIG_DIRS" = "" ]; then
  197. if [ -d /etc/xdg ]; then
  198. XDG_CONFIG_DIRS=/etc/xdg
  199. fi
  200. fi
  201. if [ -d /etc/trinity/xdg ]; then
  202. TDE_XDG_DIR="/etc/trinity/xdg"
  203. elif [ -d /etc/tde/xdg ]; then
  204. TDE_XDG_DIR="/etc/tde/xdg"
  205. elif [ -d $TDEDIR/xdg ]; then
  206. TDE_XDG_DIR="$TDEDIR/xdg"
  207. elif [ -d $TDEDIR/etc/xdg ]; then
  208. TDE_XDG_DIR="$TDEDIR/etc/xdg"
  209. elif [ -d $TDEDIR/etc/trinity/xdg ]; then
  210. TDE_XDG_DIR="$TDEDIR/etc/trinity/xdg"
  211. elif [ -d $TDEDIR/etc/tde/xdg ]; then
  212. TDE_XDG_DIR="$TDEDIR/etc/tde/xdg"
  213. elif [ -d $TDEDIR/trinity/xdg ]; then
  214. TDE_XDG_DIR="$TDEDIR/trinity/xdg"
  215. elif [ -d $TDEDIR/tde/xdg ]; then
  216. TDE_XDG_DIR="$TDEDIR/tde/xdg"
  217. fi
  218. if [ -d $TDE_XDG_DIR ]; then
  219. if [ "`echo $XDG_CONFIG_DIRS | grep \"$TDE_XDG_DIR\"`" = "" ]; then
  220. if [ "$XDG_CONFIG_DIRS" = "" ]; then
  221. XDG_CONFIG_DIRS=$TDE_XDG_DIR
  222. else
  223. XDG_CONFIG_DIRS=$TDE_XDG_DIR:$XDG_CONFIG_DIRS
  224. fi
  225. fi
  226. fi
  227. if [ "$XDG_CONFIG_DIRS" != "" ]; then
  228. export XDG_CONFIG_DIRS
  229. fi
  230. # Explicitly set $XDG_DATA_DIRS only when Trinity is not installed in /usr.
  231. # Explicitly declaring $XDG_DATA_DIRS will override the default search path of /usr/share.
  232. # Explicitly declaring $XDG_DATA_DIRS will override $TDEDIRS, which must then be
  233. # explicitly identified in the $XDG_DATA_DIRS string to remain useful.
  234. # The $TDEDIR variable is intended to be singular and $TDEDIRS plural. When $TDEDIRS
  235. # exists in the environment then parse that variable into separate directories.
  236. # $TDEDIRS should contain whatever is set in $TDEDIR. Therefore any additional directories
  237. # set in $TDEDIRS are intended to override data files found in $TDEDIR. Those additional
  238. # directories should be placed before $TDEDIR and before /usr/share.
  239. if [ "$TDEDIR" != "/usr" ] && [ -d $TDEDIR/share ]; then
  240. # If '/usr/share' is not already there, we include it at the last position.
  241. if ! is_in_path XDG_DATA_DIRS "/usr/share"; then
  242. if [ "$XDG_DATA_DIRS" = "" ]; then
  243. XDG_DATA_DIRS=/usr/share # In case XDG_DATA_DIRS is empty, to avoid a leading :
  244. else
  245. XDG_DATA_DIRS=$XDG_DATA_DIRS:/usr/share
  246. fi
  247. fi
  248. # If '/usr/local/share' is not already there, we include it before '/usr/share'
  249. if ! is_in_path XDG_DATA_DIRS "/usr/local/share"; then
  250. place_before_in_path XDG_DATA_DIRS "/usr/local/share" "/usr/share"
  251. fi
  252. # Ensure that $TDEDIR/share is always before '/usr/local/share' and '/usr/share'.
  253. if ! is_in_path XDG_DATA_DIRS "$TDEDIR/share" ||
  254. is_before_in_path XDG_DATA_DIRS "/usr/local/share" "$TDEDIR/share" ||
  255. is_before_in_path XDG_DATA_DIRS "/usr/share" "$TDEDIR/share"; then
  256. remove_from_path XDG_DATA_DIRS "$TDEDIR/share"
  257. if is_before_in_path XDG_DATA_DIRS "/usr/local/share" "/usr/share"; then
  258. place_before_in_path XDG_DATA_DIRS "$TDEDIR/share" "/usr/local/share"
  259. else
  260. place_before_in_path XDG_DATA_DIRS "$TDEDIR/share" "/usr/share"
  261. fi
  262. fi
  263. # Adds supplementary directories from TDEDIRS, if any, before TDEDIR.
  264. if [ "$TDEDIRS" != "" ]; then
  265. ifs="$IFS"; IFS=":"; set $TDEDIRS; IFS="$ifs"
  266. for dir in $*; do
  267. if ! is_in_path XDG_DATA_DIRS "$dir/share" && [ -d "$dir/share" ]; then
  268. XDG_DATA_DIRS=$dir/share:$XDG_DATA_DIRS
  269. fi
  270. done
  271. fi
  272. export XDG_DATA_DIRS
  273. fi
  274. echo "[starttde] XDG_DATA_DIRS: $XDG_DATA_DIRS" 1>&2
  275. test -n "$TDEHOME" && tdehome=`echo "$TDEHOME" | sed "s,^~/,$HOME/,"`
  276. # Allow interested applications, such as the Plasma control wrapper,
  277. # to know that this is a Trinity desktop and not a KDE one.
  278. export DESKTOP_SESSION=trinity
  279. # Create profile directory.
  280. if [ ! -d "$tdehome" ]; then
  281. echo "[starttde] Creating $tdehome" 1>&2
  282. mkdir -m 700 -p "$tdehome"
  283. fi
  284. if [ -d "$tdehome" ]; then
  285. # Run some R14 updates.
  286. R14_UPDATED="`$TDEDIR/bin/kreadconfig --file kdeglobals --group "R14 XDG Updates" --key Updated --default false`"
  287. R14_VERSION="`$TDEDIR/bin/kreadconfig --file kdeglobals --group "R14 XDG Updates" --key Version --default 0`"
  288. if [ -e $TDEDIR/bin/r14-xdg-update ]; then
  289. # Script version index is used to allow automatic rerun
  290. R14_SCRIPT="`sed -n "s/SCRIPT_VERSION=\([0-9]*\)/\1/p" $TDEDIR/bin/r14-xdg-update`"
  291. else
  292. R14_SCRIPT=0
  293. fi
  294. if [ "$R14_UPDATED" != "true" ] || [ "$R14_VERSION" -lt "$R14_SCRIPT" ]; then
  295. if [ -e $TDEDIR/bin/r14-xdg-update ]; then
  296. echo "[starttde] Running $TDEDIR/bin/r14-xdg-update script." 1>&2
  297. sh $TDEDIR/bin/r14-xdg-update
  298. EXIT_CODE="$?"
  299. else
  300. echo "[starttde] $TDEDIR/bin/r14-xdg-update does not exist." 1>&2
  301. echo " Unable to perform a profile update for Trinity release R14."
  302. fi
  303. if [ "$EXIT_CODE" != "0" ]; then
  304. exit 1
  305. fi
  306. fi
  307. fi
  308. # Please see tdestartupconfig source for usage.
  309. mkdir -m 700 -p "$tdehome/share"
  310. mkdir -m 700 -p "$tdehome/share/config"
  311. cat >"$tdehome/share/config/startupconfigkeys" <<EOF
  312. kcminputrc Mouse cursorTheme ''
  313. kcminputrc Mouse cursorSize ''
  314. kpersonalizerrc General FirstLogin true
  315. ksplashrc KSplash Theme Default
  316. kcmrandrrc Display ApplyOnStartup false
  317. kcmrandrrc [Screen0]
  318. kcmrandrrc [Screen1]
  319. kcmrandrrc [Screen2]
  320. kcmrandrrc [Screen3]
  321. kcmfonts General forceFontDPI 0
  322. EOF
  323. $TDEDIR/bin/tdestartupconfig
  324. if test $? -ne 0; then
  325. xmessage -center -geometry 500x100 "Could not start tdestartupconfig. Check your installation."
  326. fi
  327. # $tdehome/share/config/startupconfig should exist but avoid script failure if not.
  328. if [ -r "$tdehome/share/config/startupconfig" ]; then
  329. . "$tdehome/share/config/startupconfig"
  330. fi
  331. # Make sure a default wallpaper is set.
  332. if [ ! -e "$tdehome/share/config/kdesktoprc" ]; then
  333. # With Trinity this file should exist, but test first.
  334. if [ -r $TDEDIR/share/wallpapers/Trinity-lineart.svg.desktop ]; then
  335. cat >"$tdehome/share/config/kdesktoprc" <<EOF
  336. [Desktop0]
  337. Wallpaper=Trinity-lineart.svg
  338. WallpaperMode=Scaled
  339. EOF
  340. fi
  341. fi
  342. # XCursor mouse theme needs to be applied here to work even for kded or ksmserver.
  343. if test -n "$kcminputrc_mouse_cursortheme" -o -n "$kcminputrc_mouse_cursorsize" ; then
  344. kapplymousetheme "$kcminputrc_mouse_cursortheme" "$kcminputrc_mouse_cursorsize"
  345. if test $? -eq 10; then
  346. export XCURSOR_THEME=default
  347. elif test -n "$kcminputrc_mouse_cursortheme"; then
  348. export XCURSOR_THEME="$kcminputrc_mouse_cursortheme"
  349. fi
  350. if test -n "$kcminputrc_mouse_cursorsize"; then
  351. export XCURSOR_SIZE="$kcminputrc_mouse_cursorsize"
  352. fi
  353. fi
  354. if test "$kcmrandrrc_display_applyonstartup" = "true"; then
  355. # 4 screens is hopefully enough.
  356. for scrn in 0 1 2 3; do
  357. args=
  358. width="\$kcmrandrrc_screen${scrn}_width" ; eval "width=$width"
  359. height="\$kcmrandrrc_screen${scrn}_height" ; eval "height=$height"
  360. if test -n "${width}" -a -n "${height}"; then
  361. args="$args -s ${width}x${height}"
  362. fi
  363. refresh="\$kcmrandrrc_screen${scrn}_refresh" ; eval "refresh=$refresh"
  364. if test -n "${refresh}"; then
  365. args="$args -r ${refresh}"
  366. fi
  367. rotation="\$kcmrandrrc_screen${scrn}_rotation" ; eval "rotation=$rotation"
  368. if test -n "${rotation}"; then
  369. case "${rotation}" in
  370. 0)
  371. args="$args -o 0"
  372. ;;
  373. 90)
  374. args="$args -o 1"
  375. ;;
  376. 180)
  377. args="$args -o 2"
  378. ;;
  379. 270)
  380. args="$args -o 3"
  381. ;;
  382. esac
  383. fi
  384. reflectx="\$kcmrandrrc_screen${scrn}_reflectx" ; eval "reflectx=$reflectx"
  385. if test "${refrectx}" = "true"; then
  386. args="$args -x"
  387. fi
  388. reflecty="\$kcmrandrrc_screen${scrn}_reflecty" ; eval "reflecty=$reflecty"
  389. if test "${refrecty}" = "true"; then
  390. args="$args -y"
  391. fi
  392. if test -n "$args"; then
  393. xrandr $args
  394. fi
  395. done
  396. fi
  397. dl=$DESKTOP_LOCKED
  398. unset DESKTOP_LOCKED # Don't want it in the environment
  399. # Launch splash that doesn't need any TDE libraries here, before
  400. # TDE libraries are loaded into memory (which may take some time
  401. # with cold caches). Makes the splash appear sooner.
  402. # If kpersonalizer needs to be run splash will be started only later.
  403. if test -z "$dl" && test "$kpersonalizerrc_general_firstlogin" != "true"; then
  404. case "$ksplashrc_ksplash_theme" in
  405. Simple)
  406. ksplashsimple
  407. ;;
  408. *)
  409. ;;
  410. esac
  411. fi
  412. if test "$kcmfonts_general_forcefontdpi" -eq 120; then
  413. xrdb -quiet -merge -nocpp <<EOF
  414. Xft.dpi: 120
  415. EOF
  416. elif test "$kcmfonts_general_forcefontdpi" -eq 96; then
  417. xrdb -quiet -merge -nocpp <<EOF
  418. Xft.dpi: 96
  419. EOF
  420. fi
  421. # Configuration of the gtk_qt_engine if not already set.
  422. if test -n "$TDEDIRS"; then
  423. tdedirs_first=${TDEDIRS%%:*}
  424. TGTK_RC_ENGINE=$tdedirs_first/share/kgtk/gtk-qt-engine.rc.sh
  425. TGTK_RC_TDE1=$tdedirs_first/share/kgtk/.gtkrc-2.0-kde4
  426. TGTK_RC_TDE2=$tdedirs_first/share/kgtk/.gtkrc-2.0-kde-kde4
  427. else
  428. TGTK_RC_ENGINE=$TDEDIR/share/kgtk/gtk-qt-engine.rc.sh
  429. TGTK_RC_TDE1=$TDEDIR/share/kgtk/.gtkrc-2.0-kde4
  430. TGTK_RC_TDE2=$TDEDIR/share/kgtk/.gtkrc-2.0-kde-kde4
  431. fi
  432. if [ ! -e "$tdehome/env/gtk-qt-engine.rc.sh" ] && [ -e $TGTK_RC_ENGINE ]; then
  433. mkdir -p "$tdehome/env"
  434. cp -f $TGTK_RC_ENGINE "$tdehome/env"
  435. chmod 755 "$tdehome/env/gtk-qt-engine.rc.sh"
  436. fi
  437. if [ ! -e $HOME/.gtkrc-2.0-kde4 ] && [ -e $TGTK_RC_TDE1 ]
  438. then
  439. cp -f $TGTK_RC_TDE1 $HOME
  440. fi
  441. if [ ! -e $HOME/.gtkrc-2.0-kde-kde4 ] && [ -e $TGTK_RC_TDE2 ]
  442. then
  443. cp -f $TGTK_RC_TDE2 $HOME
  444. fi
  445. # Source scripts found in <localprefix>/env/*.sh and <prefixes>/env/*.sh
  446. # (where <localprefix> is $TDEHOME or ~/.trinity, and <prefixes> is where TDE is installed)
  447. #
  448. # This is where you can define environment variables that will be available to
  449. # all TDE programs. That is where to run agents using for example, eval `ssh-agent`
  450. # or eval `gpg-agent --daemon`.
  451. # Note: if you do that, you should also put "ssh-agent -k" as a shutdown script.
  452. # (Read the end of this script for running shutdown scripts).
  453. # For anything else (that doesn't set env vars, or that needs a window manager),
  454. # better use the Autostart folder.
  455. exepath=`tde-config --path exe | tr : '\n'`
  456. for prefix in `echo "$exepath" | sed -n -e 's,/bin[^/]*/,/env/,p'`; do
  457. for file in "$prefix"*.sh; do
  458. test -r "$file" && . "$file"
  459. done
  460. done
  461. # Activate the TDE font directories.
  462. #
  463. # There are 4 directories that may be used for supplying fonts for TDE.
  464. #
  465. # There are two system directories. These belong to the administrator.
  466. # There are two user directories, where the user may add her own fonts.
  467. #
  468. # The 'override' versions are for fonts that should come first in the list,
  469. # i.e. if you have a font in your 'override' directory, it will be used in
  470. # preference to any other.
  471. #
  472. # The preference order looks like this:
  473. # user override, system override, X, user, system.
  474. #
  475. # Where X is the original font database that was set up before this
  476. # script runs.
  477. usr_odir=$HOME/.fonts/kde-override
  478. usr_fdir=$HOME/.fonts
  479. # Add any user-installed font directories to the X font path.
  480. tde_fontpaths=$usr_fdir/fontpaths
  481. do_usr_fdir=1
  482. do_usr_odir=1
  483. if test -r "$tde_fontpaths" ; then
  484. savifs=$IFS
  485. IFS="
  486. "
  487. for fpath in `grep -v '^[ ]*#' < "$tde_fontpaths"` ; do
  488. rfpath=`echo $fpath | sed "s:^~:$HOME:g"`
  489. if test -s "$rfpath"/fonts.dir; then
  490. xset fp+ "$rfpath"
  491. if test "$rfpath" = "$usr_fdir"; then
  492. do_usr_fdir=0
  493. fi
  494. if test "$rfpath" = "$usr_odir"; then
  495. do_usr_odir=0
  496. fi
  497. fi
  498. done
  499. IFS=$savifs
  500. fi
  501. echo "[starttde] TDEDIR: $TDEDIR" 1>&2
  502. echo "[starttde] TDEDIRS: $TDEDIRS" 1>&2
  503. if test -n "$TDEDIRS"; then
  504. tdedirs_first=${TDEDIRS%%:*}
  505. sys_odir=$tdedirs_first/share/fonts/override
  506. sys_fdir=$tdedirs_first/share/fonts
  507. else
  508. sys_odir=$TDEDIR/share/fonts/override
  509. sys_fdir=$TDEDIR/share/fonts
  510. fi
  511. if test -n "$TDEDIRS"; then
  512. tdedirs_first=${TDEDIRS%%:*}
  513. echo "[starttde] tdedirs_first: $tdedirs_first"
  514. if [ -r $tdedirs_first/share/kgtk/preload ]; then
  515. echo "[starttde] Reading from $tdedirs_first/share/kgtk/preload"
  516. read -r TGTK_PRELOAD < $tdedirs_first/share/kgtk/preload
  517. fi
  518. else
  519. if [ -r $TDEDIR/share/kgtk/preload ]; then
  520. read -r TGTK_PRELOAD < $TDEDIR/share/kgtk/preload
  521. fi
  522. fi
  523. if [ "$TGTK_PRELOAD" != "" ]; then
  524. if [ -e /usr/lib64/libnspr4.so ]; then
  525. TGTK_NSPR_PRELOAD="/usr/lib64/libnspr4.so:"
  526. elif [ -e /usr/lib/libnspr4.so ]; then
  527. TGTK_NSPR_PRELOAD="/usr/lib/libnspr4.so:"
  528. fi
  529. export LD_PRELOAD=$TGTK_PRELOAD:$TGTK_NSPR_PRELOAD$LD_PRELOAD
  530. fi
  531. # We run mkfontdir on the user's font dirs (if we have permission) to pick
  532. # up any new fonts they may have installed. If mkfontdir fails, we still
  533. # add the user's dirs to the font path, as they might simply have been made
  534. # read-only by the administrator, for whatever reason.
  535. # Only do usr_fdir and usr_odir if they are *not* listed in fontpaths.
  536. if [ -e $sys_odir/fonts.dir ]
  537. then
  538. xset +fp "$sys_odir"
  539. fi
  540. test $do_usr_odir -eq 1 && test -d "$usr_odir" && (mkfontdir "$usr_odir" ; xset +fp "$usr_odir")
  541. test $do_usr_fdir -eq 1 && test -d "$usr_fdir" && (mkfontdir "$usr_fdir" ; xset fp+ "$usr_fdir")
  542. test -d "$sys_fdir" && xset fp+ "$sys_fdir"
  543. # Ask X11 to rebuild its font list.
  544. xset fp rehash
  545. # Set a left cursor instead of the standard X11 "X" cursor, since I've heard
  546. # from some users that they're confused and don't know what to do. This is
  547. # especially necessary on slow machines, where starting TDE takes one or two
  548. # minutes until anything appears on the screen.
  549. #
  550. # If the user has overwritten fonts, the cursor font may be different now
  551. # so don't move this up.
  552. #
  553. xsetroot -cursor_name left_ptr
  554. # Get Ghostscript to look into user's TDE fonts dir for additional Fontmap.
  555. if test -n "$GS_LIB" ; then
  556. GS_LIB=$usr_fdir:$GS_LIB
  557. export GS_LIB
  558. else
  559. GS_LIB=$usr_fdir
  560. export GS_LIB
  561. fi
  562. # Link "tmp" "socket" and "cache" resources to directory in $TMP.
  563. # Creates:
  564. # - a directory $TMP/tde-$USER and is linked from $TDEHOME/tmp-$HOSTNAME to it.
  565. # - a directory $TMP/tdesocket-$USER and is linked from $TDEHOME/socket-$HOSTNAME to it.
  566. # - a directory /var/tmp/tdecache-$USER and is linked from $TDEHOME/cache-$HOSTNAME to it.
  567. # Note: temporary locations can be overridden through the TDETMP and TDEVARTMP
  568. # environment variables.
  569. for resource in tmp cache socket; do
  570. if ! lnusertemp $resource >/dev/null; then
  571. echo "[starttde] Call to lnusertemp failed (temporary directories full?). Check your installation." 1>&2
  572. xmessage -center -geometry 600x100 "Call to lnusertemp failed (temporary directories full?). Check your installation."
  573. exit 1
  574. fi
  575. done
  576. # In case of dcop sockets left by a previous session, cleanup.
  577. $TDEDIR/bin/dcopserver_shutdown
  578. echo "[starttde] Starting Trinity..." 1>&2
  579. # Start tde_dbus_hardwarecontrol at background
  580. if [ -x $TDEDIR/bin/tde_dbus_hardwarecontrol ]; then
  581. (
  582. TDE_DBUS=$(dbus-send --system --print-reply --dest=org.freedesktop.DBus \
  583. /org/freedesktop/DBus org.freedesktop.DBus.StartServiceByName \
  584. string:org.trinitydesktop.hardwarecontrol \
  585. uint32:0 | \
  586. sed -n "s| *uint32 \([0-9]*\).*|\1|p")
  587. case "$TDE_DBUS" in
  588. 2)
  589. TDE_DBUS_STATE="running"
  590. ;;
  591. 1)
  592. TDE_DBUS_STATE="started"
  593. ;;
  594. *)
  595. TDE_DBUS_STATE="not started"
  596. ;;
  597. esac
  598. echo "[starttde] Trinity hardware control dbus daemon $TDE_DBUS_STATE." 1>&2
  599. )&
  600. fi
  601. # Detect any running Xorg composition managers.
  602. $TDEDIR/bin/kdetcompmgr
  603. # Run KPersonalizer before the session if this is the first login.
  604. if test "$kpersonalizerrc_general_firstlogin" = "true"; then
  605. if [ ! -x $TDEDIR/bin/kpersonalizer ]; then
  606. echo "[starttde] kpersonalizer not found! Please install in order to properly configure your user profile." 1>&2
  607. else
  608. # Start only dcopserver, don't start whole tdeinit (takes too long).
  609. echo "[starttde] Running kpersonalizer..." 1>&2
  610. $TDEDIR/bin/dcopserver
  611. $TDEDIR/bin/twin --lock &
  612. $TDEDIR/bin/kpersonalizer --before-session
  613. # Handle kpersonalizer restarts (language change).
  614. while test $? -eq 1; do
  615. $TDEDIR/bin/kpersonalizer --r --before-session
  616. done
  617. $TDEDIR/bin/dcopquit twin
  618. $TDEDIR/bin/dcopserver_shutdown --wait
  619. fi
  620. fi
  621. # Apply any user-specific display configuration settings
  622. $TDEDIR/bin/tdeinit_displayconfig
  623. EXIT_CODE="$?"
  624. # Remove moodin cache if we have a new wallpaper installed, jriddell. Distro-specific.
  625. if [ -d "$tdehome/share/apps/ksplash/cache/Moodin/kubuntu" ]; then
  626. if [ /usr/share/wallpapers/kubuntu-wallpaper.png -nt "$tdehome/share/apps/ksplash/cache/Moodin/kubuntu/" ]; then
  627. rm -rf "$tdehome/share/apps/ksplash/cache/Moodin/kubuntu/"
  628. fi
  629. fi
  630. if test -z "$dl"; then
  631. # The splashscreen and progress indicator.
  632. case "$ksplashrc_ksplash_theme" in
  633. None)
  634. ;; # Nothing.
  635. Simple)
  636. if test "$kpersonalizerrc_general_firstlogin" = "true"; then
  637. $TDEDIR/bin/ksplashsimple
  638. fi # Otherwise started earlier.
  639. ;;
  640. *)
  641. $TDEDIR/bin/ksplash --nodcop
  642. ;;
  643. esac
  644. fi
  645. # Mark that full TDE session is running (for example, Konqueror preloading works only
  646. # with full TDE running). The TDE_FULL_SESSION property can be detected by
  647. # any X client connected to the same X session, even if not launched
  648. # directly from the TDE session but for example, using "ssh -X", tdesu. $TDE_FULL_SESSION
  649. # however guarantees that the application is launched in the same environment
  650. # like the TDE session and that for example, TDE utilities/libraries are available.
  651. # The matching tests are:
  652. # For $TDE_FULL_SESSION:
  653. # if test -n "$TDE_FULL_SESSION"; then ... whatever
  654. # For TDE_FULL_SESSION property:
  655. # xprop -root | grep "^TDE_FULL_SESSION" >/dev/null 2>/dev/null
  656. # if test $? -eq 0; then ... whatever
  657. #
  658. # Additionally there is $TDE_SESSION_UID with the uid of the user
  659. # running the TDE session. It should be rarely needed (for example,
  660. # after sudo to prevent desktop-wide functionality in the new user's kded).
  661. #
  662. TDE_FULL_SESSION=true
  663. export TDE_FULL_SESSION
  664. xprop -root -f TDE_FULL_SESSION 8s -set TDE_FULL_SESSION true
  665. echo "[starttde] TDE_FULL_SESSION: $TDE_FULL_SESSION" 1>&2
  666. TDE_SESSION_UID=`id -u`
  667. export TDE_SESSION_UID
  668. echo "[starttde] TDE_SESSION_UID: $TDE_SESSION_UID" 1>&2
  669. # We set LD_BIND_NOW to increase the efficiency of tdeinit.
  670. # tdeinit unsets this variable before loading applications.
  671. LD_BIND_NOW=true $TDEDIR/bin/start_tdeinit_wrapper --new-startup +kcminit_startup
  672. if test $? -ne 0; then
  673. # Startup error
  674. echo "[starttde] Could not start tdeinit. Check your installation." 1>&2
  675. xmessage -center -geometry 500x100 "Could not start tdeinit. Check your installation."
  676. fi
  677. echo "[starttde] tdeinit started successfully." 1>&2
  678. # Finally, give the session control to the session manager.
  679. # See tdebase/ksmserver for the description of the rest of the startup sequence.
  680. # When set, the TDEWM environment variable will be used as Trinity's
  681. # window manager instead of twin.
  682. # When TDEWM is not set, ksmserver will ensure twin is started.
  683. # kwrapper is used to reduce startup time and memory usage.
  684. # kwrapper does not return useful error codes such as the exit code of ksmserver.
  685. # We only check for 255, which means the ksmserver process could not be
  686. # started. Any problems thereafter, for example, ksmserver failing to initialize,
  687. # will remain undetected.
  688. # tdeinit_phase1 is still experimental.
  689. $TDEDIR/bin/tdeinit_phase1
  690. EXIT_CODE="$?"
  691. # If tdeinit_phase1 should cause problems, here is the old way:
  692. # test -n "$TDEWM" && TDEWM="--windowmanager $TDEWM"
  693. # $TDEDIR/bin/kwrapper $TDEDIR/bin/ksmserver $TDEWM
  694. # EXIT_CODE="$?"
  695. if test $EXIT_CODE -eq 255; then
  696. # Startup error
  697. echo "[starttde] An error was detected while attempting to load the session manager. Please check your installation for problems." 1>&2
  698. xmessage -center -geometry 500x100 "An error was detected while attempting to load the session manager. Please check your installation for problems."
  699. fi
  700. # Wait if there's any crashhandler shown.
  701. while $TDEDIR/bin/dcop | grep -q ^drkonqi- ; do
  702. sleep 5
  703. done
  704. echo "[starttde] Shutting down Trinity..." 1>&2
  705. # Clean up.
  706. $TDEDIR/bin/tdeinit_shutdown
  707. $TDEDIR/bin/dcopserver_shutdown --wait
  708. $TDEDIR/bin/artsshell -q terminate
  709. # KDE4 support.
  710. if [ -f /usr/bin/kdeinit4_shutdown ]; then
  711. /usr/bin/kde4 kdeinit4_shutdown 2>/dev/null
  712. fi
  713. echo "[starttde] Running Trinity shutdown scripts..." 1>&2
  714. # Run scripts found in shutdown directories. Those locations are:
  715. # * $TDEHOME/shutdown
  716. # * $PREFIX/shutdown
  717. # * $TDEDIRS/shutdown ($TDEDIRS, not $TDEDIR)
  718. # Presumed is $TDEDIRS/bin exists. Create $TDEDIRS/bin even when
  719. # only using the shutdown directory or this snippet will fail to find
  720. # that shutdown directory.
  721. for prefix in `echo "$exepath" | sed -n -e 's,/bin[^/]*/,/shutdown/,p'`; do
  722. for file in `ls "$prefix" 2> /dev/null | egrep -v '(~|\.bak)$'`; do
  723. if [ -x "${prefix}${file}" ]; then
  724. echo "[starttde] Running ${prefix}${file}." 1>&2
  725. sh ${prefix}${file}
  726. fi
  727. done
  728. done
  729. unset TDE_FULL_SESSION
  730. xprop -root -remove TDE_FULL_SESSION
  731. unset TDE_SESSION_UID
  732. echo "[starttde] Trinity shutdown complete." 1>&2