s243a

/usr/libexec/Xorg_vb.wrap

May 6th, 2019
621
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.71 KB | None | 0 0
  1. #!/bin/bash
  2. . /usr/libexec/Xorg_Wrap_Fns.sh
  3. ARGS=()
  4. euid1=`id -u`
  5. uid1=`id -u -r`
  6. USER1=`id -nu "$uid1"`
  7. GROUP1="`su -c 'id -gn' $USER1`"
  8. HOME1=`eval 'echo ~'"$USER1"`
  9. i=0
  10. for x in $@; do
  11.   if [ ${#ARGS[@]} -gt 1 ]; then
  12.     if [ "${ARGS[-1]}" = "-auth" ]; then
  13.       XAUTH="$x" #See
  14.     elif [ "${ARGS[-1]}" = "-f" ]; then
  15.       XAUTHORITY="$x"
  16.     fi
  17.   fi
  18.   case "$x" in
  19.   --user-name=*) #remove all options
  20.     #Consider allowing non root users to do this but work out
  21.     #security percautions first.
  22.     if [ $uid1 -eq 0 ]; then
  23.       USER="${x#--user-name=}"
  24.     fi ;;
  25.   --config-env=*)
  26.     CONFIG_ENV="${x#--config-env=}" ;;
  27.   --merge-x-resources=*)  
  28.     MERGE_X_RESOURCES="${x#--merge-x-resources=}" ;;  
  29.   --merge-x-resources)  
  30.     MERGE_X_RESOURCES=1 ;;
  31.   --xrand-setup=*)
  32.     XRAND_SETUP="${x#--xrand-setup=}" ;;
  33.   --set-x=*)
  34.     SET_X="${x#--set-x=}" ;;
  35.   --set-x)
  36.     SET_X=1 ;;
  37.   --xinit)
  38.     XINIT=1 ;;
  39.   --xinitrc=*)
  40.     XINITRC_PATH="${x#--xinitrc=}" ;;
  41.   --lauch-wm=*)
  42.     LAUNCH_WM="${x#--lauch-wm=}" ;;
  43.   --lauch-wm)
  44.     LAUNCH_WM=1 ;;
  45.   --maybe-start-desktop=*)
  46.     MAYBE_START_DESTKOP="${x#--maybe-start-desktop=}" ;;
  47.   --maybe-start-desktop)
  48.     MAYBE_START_DESTKOP=1 ;;
  49.   --xinit-misc=*)
  50.     XINIT_MISC="${x#--xinit-misc=}" ;;
  51.   --xinit-misc)
  52.     XINIT_MISC=1 ;;
  53.   vt*)
  54.     VT=$x #"${x#vt}" ;;
  55.     ARGS+=($x) ;;
  56.   *) ARGS+=($x) ;;
  57.  
  58.   esac
  59.   let "i++"
  60. done
  61. #Well set the defaults here (may change)
  62. #Maybe move these defaults to a config file.
  63. [ -z "$CONFIG_ENV" ] && CONFIG_ENV=1
  64. [ -z "$MERGE_X_RESOURCES" ] && MERGE_X_RESOURCES=1
  65. [ -z "$XRAND_SETUP" ] && XRAND_SETUP=1
  66. [ -z "$SET_X" ] && SET_X=1
  67. [ -z "$XINIT" ] && XINIT=0
  68. [ -z "$MAYBE_START_DESTKOP" ] && MAYBE_START_DESTKOP=0
  69. [ -z "$LAUNCH_WM" ] && LAUNCH_WM=1
  70. [ -z "$XINIT_MISC" ] && XINIT_MISC=1
  71. #rox ${ARGS[*]}
  72.  
  73.  
  74. if  [ -z "$VT" ]; then #Alternativly we could use slim default which is vt07
  75.   if [ `fgconsole` -gt 9 ]; then
  76.     VT=`fgconsole`
  77.   else
  78.     VT=vt0`fgconsole`
  79.   fi
  80.   RGS+=($VT)
  81. fi
  82. #https://stackoverflow.com/questions/27669950/difference-between-euid-and-uid
  83.  
  84.  
  85.  
  86. [ -z "$USER" ] && USER=USER1
  87. export $USER
  88. euid=`su $USER -c 'id -u -r'`
  89. uid=`su $USER -c 'id -u'`
  90. GROUP="`su -c 'id -gn' $USER`"
  91. HOME=`eval 'echo ~'"$USER"`
  92.  
  93. Xorg &
  94. #case $USER in
  95. #tux) #Create special cases for when Xorg.wrap doesn't work
  96. #  /usr/libexec/Xorg "${ARGS[@]}" &
  97. #  #copy_xauth=1 #I'm not sure if we need to do this
  98. #  #since slim has it's own xauth located at:
  99. #  # /var/run/slim.auth
  100. #  #See: https://wiki.archlinux.org/index.php/SLiM
  101. #  ;;
  102. #*)
  103. #  su $USER -c '/usr/libexec/Xorg.warap '"${ARGS[@]}" &
  104. #  ;;
  105. #esac
  106. #/etc/rc.d/rc.vbox
  107.  
  108. if [ "`users`" = "$USER $GROUP" ]; then
  109.   XAUTH="/var/run/slim.auth"
  110. else
  111.   XAUTH="/usr/bin/xauth"
  112. fi
  113. export XAUTH
  114. [ -z "$XAUTHORITY" ] && XAUTHORITY=/root/.Xauthority
  115. [ -e "$XAUTHORITY" ] && cp --remove-destination -f $XAUTHORITY $HOME/.Xauthority && chown $USER:$GROUP $HOME/.Xauthority && \
  116. export XAUTHORITY=$HOME/.Xauthority
  117.   if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS"; then
  118.     set +x
  119.     if test -z "$XDG_RUNTIME_DIR" -o ! -S "$XDG_RUNTIME_DIR/bus" -o ! -O "$XDG_RUNTIME_DIR/bus"; then
  120.         eval "$(dbus-launch --sh-syntax --exit-with-session)"
  121.     fi
  122.     set -x
  123.   fi
  124.  
  125. unset XDG_CONFIG_HOME
  126. unset XDG_DATA_HOME
  127. unset XDG_CACHE_HOME
  128. #The following is probably redundant:
  129.  
  130. if [ $CONFIG_ENV -eq 1 ]; then
  131.   config_xdg_env
  132.   if [ $MERGE_X_RESOURCES -eq 1 ]; then
  133.     merge_xorg_resources
  134.   fi
  135. fi
  136.  
  137. #if [ -e /tmp/videomode ];then #xvesa only: testing a video mode
  138. # video-wizard &
  139. #fi
  140. #[ -f /usr/local/bin/agenda_chk ] && agenda_chk &
  141.  
  142. #0.9.8 sync selection-buffer and clipboard. only useful for older apps
  143. #such as rxvt that use the selection-buffer...
  144. [ -f /usr/bin/autocutsel ] && /usr/bin/autocutsel &
  145. #...disadvantage of this is it creates a little square bottom-right of screen
  146.  
  147. if [ -f "/etc/rc.d/rc.vbox" ]; then
  148.   if [ -x  "/etc/rc.d/rc.vbox" ]; then
  149.     /etc/rc.d/rc.vbox
  150.   else
  151.     sh /etc/rc.d/rc.vbox
  152.   fi
  153. fi
  154. #vboxadd start #I presume this is already started.
  155. #VBoxClient --clipboard
  156. if [ $XRAND_SETUP -eq 1 ]; then
  157.   do_xrand_setup
  158. fi
  159.  
  160. if [ $SET_X -eq 1 ]; then
  161.   set_x_items
  162. fi
  163. ##Well set the defaults here (may change)
  164. #[ -z "$CONFIG_ENV" ] && CONFIG_ENV=1
  165. #[ -z "$XRAND_SETUP" ] && XRAND_SETUP=1
  166. #[ -z "$SET_X" ] && SET_X=1
  167.  
  168. start_desktop_if_no_autostart
  169.  
  170. xinit_misc
  171.  
  172. if [ -n "$XINITRC_PATH" ] || [ -n "$XINIT" ] && [ "$XINIT" -eq 1 ]; then
  173.  
  174.   [ -z "$XINITRC_PATH" ] && XINITRC_PATH=$HOME/.xinitrc
  175.   if [ -x $XINITRC_PATH ]; then
  176.     maybe_su_exec $USER -c "$XINITRC_PATH"
  177.   else
  178.     maybe_su_exec $USER -c "sh $XINITRC_PATH"
  179.   fi
  180. elif [ $LAUNCH_WM -eq 1 ]; then
  181.   launch_wm
  182. fi
Advertisement
Add Comment
Please, Sign In to add comment