[linux] Matchbox (1): startup script

Script execution order

Start the X server

/etc/rc5.d/S01xserver-nodm –> ../init.d/xserver-nodm –>
Corresponding process:
/bin/sh /etc/rc5.d/S01xserver-nodm start background

xinit /etc/X11/Xsession–>
对应进程:
xinit /etc/X11/Xsession – /usr/bin/Xorg -br -pn -nolisten tcp +iglx
/usr/bin/Xorg :0 -br -pn -nolisten tcp +iglx

Start the desktop management program Matchbox

/etc/X11/Xsession.d/90xXWindowManager.sh–>
/usr/bin/x-session-manager—>
/etc/matchbox/session
最后启动四个程序
matchbox-window-manager -theme Sato -use_desktop_mode decorated -use_cursor yes
matchbox-desktop
matchbox-panel –titlebar –start-applets showdesktop,windowselector –end-applets clock,battery,keyboard,systray,startup-notify,notify
matchbox-keyboard -d

Details of each script

etc/rc5.d/S01xserver-nodm –> ../init.d/xserver-nodm

#!/bin/sh
#
### BEGIN INIT INFO
# Provides: xserver
# Required-Start: $local_fs $remote_fs dbus
# Required-Stop: $local_fs $remote_fs
# Default-Start:     5
# Default-Stop:      0 1 2 3 6
### END INIT INFO


. /etc/init.d/functions

for x in $(cat /proc/cmdline); do
        case $x in
        x11=false)
        echo "X Server disabled" 
        exit 0;
                ;;
        esac
done

case "$1" in
  start)
    # We don't want this script to block the rest of the boot process
    if [ "$2" != "background" ]; then
      $0 $1 background &
    else
       # work around from /etc/X11/Xinit
       export USER=root
       export HOME=/home/root
       if [ ! -d $HOME ] && [ -d /root ]; then
         HOME=/root
       fi

       . /etc/profile

       echo "Starting Xserver"
       . /etc/X11/xserver-common
#$XSERVER和$ARGS在xserver-common中定义,$XSERVER=Xorg,下面的步骤是启动X服务器Xorg
#/etc/X11/Xsession是X客户端,也就是桌面管理程序
#xinit的用法为:xinit [[client] options ] [-- [server] [display] options]
       xinit /etc/X11/Xsession -- `which $XSERVER` $ARGS >/var/log/Xsession.log 2>&1
    fi
  ;;

  stop)
        echo "Stopping XServer"
        killproc xinit
  ;;

  restart)
    $0 stop
        sleep 1
        $0 start
  ;;

  *)
        echo "usage: $0 { start | stop | restart }"
  ;;
esac

exit 0

etc/X11/Xsession

#!/bin/sh

# this location MUST be consistent with /etc/X11/gpe-login.pre-session
HOME_VOLATILE=/home/$USER/ramdisk
export HOME_VOLATILE

. /etc/profile

if [ -f $HOME/.profile ]; then
 . $HOME/.profile
fi



if [ -f /usr/bin/dbus-launch ]; then
  ## test for an existing bus daemon, just to be safe
  if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
     ## if not found, launch a new one
     eval `/usr/bin/dbus-launch --auto-syntax --exit-with-session`
     echo "D-BUS per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS"
  fi  
fi

SYSSESSIONDIR=/etc/X11/Xsession-gpe.d

if [ ! -d $SYSSESSIONDIR ]; then
  SYSSESSIONDIR=/etc/X11/Xsession.d
fi

# Use run-parts to source every file in the session directory; we source
# instead of executing so that the variables and functions defined above
# are available to the scripts, and so that they can pass variables to each
# other.
# Can't use run-parts like this, busybox doesn't support it. Use ls instead
#SESSIONFILES=$(run-parts --list $SYSSESSIONDIR)

SESSIONFILES=`ls -X $SYSSESSIONDIR`
if [ -n "$SESSIONFILES" ]; then
  for SESSIONFILE in $SESSIONFILES; do
  # Test if script is executable first before sourcing it
    if [ -x "$SYSSESSIONDIR/$SESSIONFILE" ]; then
      . $SYSSESSIONDIR/$SESSIONFILE
    fi
  done
fi

exit 0

/etc/X11/Xsession.d/90xXWindowManager.sh

  if [ -x $HOME/.Xsession ]; then
      exec $HOME/.Xsession
  elif [ -x /usr/bin/x-session-manager ]; then
      exec /usr/bin/x-session-manager
  else
      exec /usr/bin/x-window-manager
  fi

/usr/bin/x-session-manager

#!/bin/sh
#
# Very simple session manager for matchbox tools
#

# Uncomment below to enable parsing of debian menu entrys
# export MB_USE_DEB_MENUS=1

if [ -e $HOME/.matchbox/session ]
then
exec $HOME/.matchbox/session
fi

if [ -e /etc/matchbox/session ]
then
exec /etc/matchbox/session
fi

# Default files to run if $HOME/.matchbox/session or /etc/matchbox/session
# dont exist.

matchbox-desktop &
matchbox-panel &
exec matchbox-window-manager $@

/etc/matchbox/session

#!/bin/sh

. /etc/formfactor/config

if [ "$HAVE_TOUCHSCREEN" = "1" ]; then
    SHOWCURSOR="no"
else
    SHOWCURSOR="yes"
fi

if [ "$HAVE_KEYBOARD" = "1" ]; then
    KEYBOARD_APPLET=""
else
    KEYBOARD_APPLET="keyboard"
fi


matchbox-desktop &

# Lines containing feature-[foo] are removed at build time if the machine
# doesn't have the feature "foo".

START_APPLETS=showdesktop,windowselector
END_APPLETS=clock,battery,$KEYBOARD_APPLET,systray,startup-notify,notify

matchbox-panel --titlebar --start-applets $START_APPLETS --end-applets $END_APPLETS &

exec matchbox-window-manager -theme Sato -use_desktop_mode decorated -use_cursor $SHOWCURSOR $@

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325523146&siteId=291194637