Advertisement
Guest User

/etc/xdg/xfce4/xinitrc

a guest
Mar 15th, 2014
822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 10.03 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # fix broken $UID on some system...
  4. if test "x$UID" = "x"; then
  5.     if test -x /usr/xpg4/bin/id; then
  6.         UID=`/usr/xpg4/bin/id -u`;
  7.     else
  8.         UID=`id -u`;
  9.     fi
  10. fi
  11.  
  12. # set $XDG_MENU_PREFIX to "xfce-" so that "xfce-applications.menu" is picked
  13. # over "applications.menu" in all Xfce applications.
  14. if test "x$XDG_MENU_PREFIX" = "x"; then
  15.   XDG_MENU_PREFIX="xfce-"
  16.   export XDG_MENU_PREFIX
  17. fi
  18.  
  19. # set DESKTOP_SESSION so that one can detect easily if an Xfce session is running
  20. if test "x$DESKTOP_SESSION" = "x"; then
  21.   DESKTOP_SESSION="xfce"
  22.   export DESKTOP_SESSION
  23. fi
  24.  
  25. # $XDG_CONFIG_HOME defines the base directory relative to which user specific
  26. # configuration files should be stored. If $XDG_CONFIG_HOME is either not set
  27. # or empty, a default equal to $HOME/.config should be used.
  28. if test "x$XDG_CONFIG_HOME" = "x" ; then
  29.   XDG_CONFIG_HOME=$HOME/.config
  30. fi
  31. [ -d "$XDG_CONFIG_HOME" ] || mkdir "$XDG_CONFIG_HOME"
  32.  
  33. # $XDG_CACHE_HOME defines the base directory relative to which user specific
  34. # non-essential data files should be stored. If $XDG_CACHE_HOME is either not
  35. # set or empty, a default equal to $HOME/.cache should be used.
  36. if test "x$XDG_CACHE_HOME" = "x" ; then
  37.   XDG_CACHE_HOME=$HOME/.cache
  38. fi
  39. [ -d "$XDG_CACHE_HOME" ] || mkdir "$XDG_CACHE_HOME"
  40.  
  41.  
  42. # set up XDG user directores.  see
  43. # http://freedesktop.org/wiki/Software/xdg-user-dirs
  44. if which xdg-user-dirs-update >/dev/null 2>&1; then
  45.     xdg-user-dirs-update
  46. fi
  47.  
  48. if test -f "$XDG_CONFIG_HOME/user-dirs.dirs"; then
  49.     . "$XDG_CONFIG_HOME/user-dirs.dirs"
  50.     # i'm deliberately not 'export'-ing the XDG_ vars, because you shouldn't
  51.     # rely on the env vars inside apps, since the file could be changed at
  52.     # any time by the user.  this is solely here for migration purposes.
  53.  
  54.     # a bit of user dir migration...
  55.     if test -d "$HOME/Desktop" -a ! -L "$HOME/Desktop" \
  56.             -a "$XDG_DESKTOP_DIR" \
  57.             -a "$HOME/Desktop" != "$XDG_DESKTOP_DIR"
  58.     then
  59.         echo "Migrating $HOME/Desktop to $XDG_DESKTOP_DIR..."
  60.         test -d "$XDG_DESKTOP_DIR" && rmdir "$XDG_DESKTOP_DIR"
  61.         mv "$HOME/Desktop" "$XDG_DESKTOP_DIR" || echo "Desktop migration failed" >&2
  62.     fi
  63.  
  64.     if test -d "$HOME/Templates" -a ! -L "$HOME/Templates" \
  65.             -a "$XDG_TEMPLATES_DIR" \
  66.             -a "$HOME/Templates" != "$XDG_TEMPLATES_DIR"
  67.     then
  68.         echo "Migrating $HOME/Templates to $XDG_TEMPLATES_DIR..."
  69.         test -d "$XDG_TEMPLATES_DIR" && rmdir "$XDG_TEMPLATES_DIR"
  70.         mv "$HOME/Templates" "$XDG_TEMPLATES_DIR" || echo "Templates migration failed" >&2
  71.     fi
  72. fi
  73.  
  74.  
  75. # Modify libglade and glade environment variables so that
  76. # it will find the files installed by Xfce
  77. LIBGLADE_MODULE_PATH="$LIBGLADE_MODULE_PATH:"
  78. GLADE_CATALOG_PATH="$GLADE_CATALOG_PATH:"
  79. GLADE_PIXMAP_PATH="$GLADE_PIXMAP_PATH:"
  80. GLADE_MODULE_PATH="$GLADE_MODULE_PATH:"
  81. export LIBGLADE_MODULE_PATH
  82. export GLADE_CATALOG_PATH
  83. export GLADE_PIXMAP_PATH
  84. export GLADE_MODULE_PATH
  85.  
  86. # Export GTK_PATH so that GTK+ can find the Xfce theme engine
  87. # https://bugzilla.xfce.org/show_bug.cgi?id=7483
  88. #GTK_PATH="$GTK_PATH:/usr/lib/x86_64-linux-gnu/gtk-2.0"
  89. #export GTK_PATH
  90.  
  91. # For now, start with an empty list
  92. XRESOURCES=""
  93.  
  94. # Has to go prior to merging Xft.xrdb, as its the "Defaults" file
  95. test -r "/etc/xdg/xfce4/Xft.xrdb" && XRESOURCES="$XRESOURCES /etc/xdg/xfce4/Xft.xrdb"
  96. test -r $HOME/.Xdefaults && XRESOURCES="$XRESOURCES $HOME/.Xdefaults"
  97.  
  98. BASEDIR=$XDG_CONFIG_HOME/xfce4
  99. if test -r "$BASEDIR/Xft.xrdb"; then
  100.   XRESOURCES="$XRESOURCES $BASEDIR/Xft.xrdb"
  101. elif test -r "$XFCE4HOME/Xft.xrdb"; then
  102.   mkdir -p "$BASEDIR"
  103.   cp "$XFCE4HOME/Xft.xrdb" "$BASEDIR"/
  104.   XRESOURCES="$XRESOURCES $BASEDIR/Xft.xrdb"
  105. fi
  106.  
  107. # merge in X cursor settings
  108. test -r "$BASEDIR/Xcursor.xrdb" && XRESOURCES="$XRESOURCES $BASEDIR/Xcursor.xrdb"
  109.  
  110. # ~/.Xresources contains overrides to the above
  111. test -r "$HOME/.Xresources" && XRESOURCES="$XRESOURCES $HOME/.Xresources"
  112.  
  113. # load all X resources (adds /dev/null to avoid an empty list that would hang the process)
  114. cat /dev/null $XRESOURCES | xrdb -nocpp -merge -
  115.  
  116. # load local modmap
  117. test -r $HOME/.Xmodmap && xmodmap $HOME/.Xmodmap
  118.  
  119. # Use dbus-launch if installed.
  120. if test x"$DBUS_SESSION_BUS_ADDRESS" = x""; then
  121.     if which dbus-launch >/dev/null 2>&1; then
  122.         eval `dbus-launch --sh-syntax --exit-with-session`
  123.         # some older versions of dbus don't export the var properly
  124.         export DBUS_SESSION_BUS_ADDRESS
  125.     else
  126.         echo "Could not find dbus-launch; Xfce will not work properly" >&2
  127.     fi
  128. fi
  129.  
  130. # launch gpg-agent or ssh-agent if enabled.
  131. ssh_agent_enabled=`xfconf-query -c xfce4-session -p /startup/ssh-agent/enabled 2> /dev/null`
  132. if test "$ssh_agent_enabled" != "false"; then
  133.     # if the user has pam_ssh installed, it will start ssh-agent for us, but
  134.     # of course won't start gpg-agent.  so, if ssh-agent is already running,
  135.     # but we want gpg-agent (and that's not running yet) start gpg-agent
  136.     # without ssh support
  137.  
  138.     ssh_agent_type=`xfconf-query -c xfce4-session -p /startup/ssh-agent/type 2> /dev/null`
  139.     if test -z "$ssh_agent_type"; then
  140.         if which gpg-agent >/dev/null 2>&1; then
  141.             ssh_agent_type=gpg-agent
  142.         else
  143.             ssh_agent_type=ssh-agent
  144.         fi
  145.     fi
  146.  
  147.     # ignore stale ssh-agents
  148.     if test "$SSH_AGENT_PID"; then
  149.         if ! kill -0 $SSH_AGENT_PID; then
  150.             unset SSH_AGENT_PID
  151.             unset SSH_AUTH_SOCK
  152.         fi
  153.     fi
  154.  
  155.     case "$ssh_agent_type" in
  156.         gpg-agent)
  157.             if test -z "$SSH_AGENT_PID"; then
  158.                 eval `gpg-agent --daemon --enable-ssh-support --write-env-file $XDG_CACHE_HOME/gpg-agent-info`
  159.                 ssh_agent_kill_cmd="kill -INT $SSH_AGENT_PID; rm -f $XDG_CACHE_HOME/gpg-agent-info"
  160.             elif test -z "$GPG_AGENT_INFO"; then
  161.                 echo "ssh-agent is already running; starting gpg-agent without ssh support"
  162.                 eval `gpg-agent --daemon --write-env-file $XDG_CACHE_HOME/gpg-agent-info`
  163.                 ssh_agent_kill_cmd="pkill -INT ^gpg-agent\$; rm -f $XDG_CACHE_HOME/gpg-agent-info"
  164.             else
  165.                 echo "gpg-agent is already running"
  166.             fi
  167.             ;;
  168.  
  169.         ssh-agent)
  170.             if test -z "$SSH_AGENT_PID"; then
  171.                 eval `ssh-agent -s`
  172.                 ssh_agent_kill_cmd="ssh-agent -s -k"
  173.             else
  174.                 echo "ssh-agent is already running"
  175.             fi
  176.             ;;
  177.  
  178.         *)
  179.             echo "Unrecognized agent type '$ssh_agent_type'" >&2
  180.             ;;
  181.     esac
  182. fi
  183.  
  184.  
  185. # launch a screensaver if enabled.  do not launch if we're root or if
  186. # we're in a VNC session.
  187. screensaver_enabled=`xfconf-query -c xfce4-session -p /startup/screensaver/enabled 2> /dev/null`
  188. if test $UID -gt 0 -a -z "$VNCSESSION" -a "$screensaver_enabled" != "false"; then
  189.     screensaver_type=`xfconf-query -c xfce4-session -p /startup/screensaver/type 2> /dev/null`
  190.  
  191.     case "$screensaver_type" in
  192.         xscreensaver)
  193.             xscreensaver -no-splash &
  194.             ;;
  195.  
  196.         gnome-screensaver)
  197.             gnome-screensaver &
  198.             ;;
  199.  
  200.         *)
  201.             if test x"`which xscreensaver 2>/dev/null`" != x""; then
  202.                 xscreensaver -no-splash &
  203.             elif test x"`which gnome-screensaver 2>/dev/null`" != x""; then
  204.                 gnome-screensaver &
  205.             fi
  206.             ;;
  207.     esac
  208. fi
  209.  
  210.  
  211. # Run xfce4-session if installed
  212. if which xfce4-session >/dev/null 2>&1; then
  213.     xfce4-session
  214.  
  215.     if test "$ssh_agent_kill_cmd"; then
  216.         echo "running '$ssh_agent_kill_cmd'"
  217.         eval "$ssh_agent_kill_cmd"
  218.     fi
  219.  
  220.     exit 0
  221. fi
  222.  
  223.  
  224. ##################
  225. # IMPORTANT NOTE #
  226. ##################
  227.  
  228. # Everything below here ONLY gets executed if you are NOT using xfce4-session
  229. # (Xfce's session manager).  If you are using the session manager, everything
  230. # below is handled by it, and the code below is not executed at all.  If you're
  231. # not sure if you're using the session manager, type 'ps -e|grep xfce4-session'
  232. # in a terminal while Xfce is running.
  233.  
  234. ##################
  235.  
  236.  
  237. # this is only necessary when running w/o xfce4-session
  238. xsetroot -solid black -cursor_name watch
  239.  
  240. # or use old-fashioned startup script otherwise
  241.  
  242. xfsettingsd &
  243. xfwm4 --daemon
  244.  
  245. # start up stuff in $XDG_CONFIG_HOME/autostart/, as that looks to be
  246. # the new standard.  if that directory doesn't exist, try the old
  247. # ~/Desktop/Autostart method.  we're not going to do any migration here.
  248. if test -d "$XDG_CONFIG_HOME/autostart"; then
  249.   for i in ${XDG_CONFIG_HOME}/autostart/*.desktop; do
  250.     grep -q -E "^Hidden=true" "$i" && continue
  251.     if grep -q -E "^OnlyShowIn=" "$i"; then
  252.       # need to test twice, as lack of the line entirely means we still run it
  253.       grep -E "^OnlyShowIn=" "$i" | grep -q 'XFCE;' || continue
  254.     fi
  255.     grep -E "^NotShowIn=" "$i" | grep -q 'XFCE;' && continue
  256.  
  257.     # check for TryExec
  258.     trycmd=`grep -E "^TryExec=" "$i" | cut -d'=' -f2`
  259.     if test "$trycmd"; then
  260.       which "$trycmd" >/dev/null 2>&1 || continue
  261.     fi
  262.  
  263.     cmd=`grep -E "^Exec=" "$i" | cut -d'=' -f2`
  264.     if test "$cmd" && which "$cmd" >/dev/null 2>&1; then
  265.       $cmd &
  266.     fi
  267.   done
  268. elif test -d "$HOME/Desktop/Autostart"; then
  269.   for i in `ls -1 -L ${HOME}/Desktop/Autostart/ 2>/dev/null`; do
  270.     if test -x $HOME/Desktop/Autostart/$i; then
  271.       $HOME/Desktop/Autostart/$i &
  272.     fi
  273.   done
  274. fi
  275.  
  276. xfdesktop&
  277. orage &
  278.  
  279. panel=`which xfce4-panel`
  280. case "x$panel" in
  281.     x|xno*)
  282.         ;;
  283.     *)
  284.         $panel
  285.         ret=$?
  286.         while test $ret -ne 0; do
  287.             xmessage -center -file - -timeout 20 -title Error <<EOF
  288. A crash occured in the panel
  289. Please report this to the xfce4-dev@xfce.org list
  290. or on http://bugs.xfce.org
  291. Meanwhile the panel will be restarted
  292. EOF
  293.             cat >&2 <<EOF
  294. A crash occured in the panel
  295. Please report this to the xfce4-dev@xfce.org list
  296. or on http://bugs.xfce.org
  297. Meanwhile the panel will be restarted
  298. EOF
  299.             $panel
  300.             ret=$?
  301.         done
  302.         ;;
  303. esac
  304.  
  305. if test "$ssh_agent_kill_cmd"; then
  306.     eval "$ssh_agent_kill_cmd"
  307. fi
  308.  
  309. xsetroot -bg white -fg red  -solid black -cursor_name watch
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement