Advertisement
Guest User

Xsession

a guest
Jan 11th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.87 KB | None | 0 0
  1. #! /bin/sh
  2. # Xsession - run as user
  3.  
  4. # This file is extracted from kde-workspace (kdm/kfrontend/genkdmconf.c)
  5. # Copyright (C) 2001-2005 Oswald Buddenhagen <ossi@kde.org>
  6.  
  7. session=$1
  8.  
  9. # Note that the respective logout scripts are not sourced.
  10. case $SHELL in
  11.   */bash)
  12.     [ -z "$BASH" ] && exec $SHELL $0 "$@"
  13.     set +o posix
  14.     [ -f /etc/profile ] && . /etc/profile
  15.     if [ -f $HOME/.bash_profile ]; then
  16.       . $HOME/.bash_profile
  17.     elif [ -f $HOME/.bash_login ]; then
  18.       . $HOME/.bash_login
  19.     elif [ -f $HOME/.profile ]; then
  20.       . $HOME/.profile
  21.     fi
  22.     ;;
  23. */zsh)
  24.     [ -z "$ZSH_NAME" ] && exec $SHELL $0 "$@"
  25.     [ -d /etc/zsh ] && zdir=/etc/zsh || zdir=/etc
  26.     zhome=${ZDOTDIR:-$HOME}
  27.     # zshenv is always sourced automatically.
  28.     [ -f $zdir/zprofile ] && . $zdir/zprofile
  29.     [ -f $zhome/.zprofile ] && . $zhome/.zprofile
  30.     [ -f $zdir/zlogin ] && . $zdir/zlogin
  31.     [ -f $zhome/.zlogin ] && . $zhome/.zlogin
  32.     emulate -R sh
  33.     ;;
  34.   */csh|*/tcsh)
  35.     # [t]cshrc is always sourced automatically.
  36.     # Note that sourcing csh.login after .cshrc is non-standard.
  37.     xsess_tmp=`mktemp /tmp/xsess-env-XXXXXX`
  38.     $SHELL -c "if (-f /etc/csh.login) source /etc/csh.login; if (-f ~/.login) source ~/.login; /bin/sh -c 'export -p' >! $xsess_tmp"
  39.     . $xsess_tmp
  40.     rm -f $xsess_tmp
  41.     ;;
  42.   *) # Plain sh, ksh, and anything we do not know.
  43.     [ -f /etc/profile ] && . /etc/profile
  44.     [ -f $HOME/.profile ] && . $HOME/.profile
  45.     ;;
  46. esac
  47.  
  48. [ -f /etc/xprofile ] && . /etc/xprofile
  49. [ -f $HOME/.xprofile ] && . $HOME/.xprofile
  50.  
  51. # run all system xinitrc shell scripts.
  52. if [ -d /etc/X11/xinit/xinitrc.d ]; then
  53.   for i in /etc/X11/xinit/xinitrc.d/* ; do
  54.   if [ -x "$i" ]; then
  55.     . "$i"
  56.   fi
  57.   done
  58. fi
  59.  
  60. # Load Xsession scripts
  61. # OPTIONFILE, USERXSESSION, USERXSESSIONRC and ALTUSERXSESSION are required
  62. # by the scripts to work
  63. xsessionddir="/etc/X11/Xsession.d"
  64. OPTIONFILE=/etc/X11/Xsession.options
  65. USERXSESSION=$HOME/.xsession
  66. USERXSESSIONRC=$HOME/.xsessionrc
  67. ALTUSERXSESSION=$HOME/.Xsession
  68.  
  69. if [ -d "$xsessionddir" ]; then
  70.     for i in `ls $xsessionddir`; do
  71.         script="$xsessionddir/$i"
  72.         echo "Loading X session script $script"
  73.         if [ -r "$script"  -a -f "$script" ] && expr "$i" : '^[[:alnum:]_-]\+$' > /dev/null; then
  74.             . "$script"
  75.         fi
  76.     done
  77. fi
  78.  
  79. if [ -d /etc/X11/Xresources ]; then
  80.   for i in /etc/X11/Xresources/*; do
  81.     [ -f $i ] && xrdb -merge $i
  82.   done
  83. elif [ -f /etc/X11/Xresources ]; then
  84.   xrdb -merge /etc/X11/Xresources
  85. fi
  86. [ -f $HOME/.Xresources ] && xrdb -merge $HOME/.Xresources
  87.  
  88. case $session in
  89.   "")
  90.     exec xmessage -center -buttons OK:0 -default OK "Sorry, $DESKTOP_SESSION is no valid session."
  91.     ;;
  92.   *)
  93.     eval exec "$session"
  94.     ;;
  95. esac
  96. exec xmessage -center -buttons OK:0 -default OK "Sorry, cannot execute $session. Check $DESKTOP_SESSION.desktop."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement