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.

841 lines
29KB

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