Advertisement
s243a

/usr/libexec/Xorg_Wrap_Fns.sh

May 6th, 2019
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.54 KB | None | 0 0
  1. set_ids(){
  2.    uid1=`id -u -r`
  3.    euid1=`id -u`
  4.    [ -z "$uid" ] && uid=${uid:-$uid1}
  5.    [ -z "$euid" ] && euid=${euid:-$euid1}
  6. }
  7. set_home(){
  8.     set_ids
  9.     USER=${USER:-`id -nu "$uid"`}
  10.     HOME=`eval 'echo ~'"$USER"`
  11. }
  12. maybe_su(){
  13.     set_ids
  14.     if [ $euid1 -eq 0 ] && \
  15.        [ $uid1 -ne $uid ] ; then
  16.       su "$@"
  17.     else
  18.       i=1
  19.       for x in "$@"; do
  20.         if [ "$x" = "-c" ]; then
  21.           next=$((i + 1))
  22.           A_CMD=${@:$next:1}
  23.           break
  24.         fi
  25.         let "i++"
  26.       done
  27.       eval "$A_CMD"
  28.     fi
  29. }
  30. maybe_su_exec(){
  31.  
  32.     if [ $euid1 -eq 0 ] && \
  33.        [ $uid1 -ne $uid ] ; then
  34.       exec su "$@"
  35.     else
  36.       i=1
  37.       for x in "$@"; do
  38.         if [ "$x" = "-c" ]; then
  39.           next=$((i + 1))
  40.           A_CMD=${@:$next:1}
  41.           break
  42.         fi
  43.         let "i++"
  44.       done
  45.       exec $A_CMD
  46.     fi
  47. }
  48.  
  49. config_xdg_env(){
  50.   [ -z "$HOME" ] && set_home
  51.   export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
  52.   if [ -f "$XDG_CONFIG_HOME"/slitaz/applications.conf ]; then
  53.     apps_conf="$XDG_CONFIG_HOME"/slitaz/applications.conf
  54.   elif [ -f "/etc/skel/.config/slitaz/applications.conf" ]; then
  55.     apps_conf="/etc/skel/.config/slitaz/applications.conf"
  56.   elif [ -f "/etc/slitaz/applications.conf" ]; then
  57.     apps_conf="/etc/slitaz/applications.conf"
  58.   fi
  59.   . "$apps_conf"
  60.  
  61.  
  62.   if [ -z "$XDG_CONFIG_HOME" ]; then
  63.     export XDG_CONFIG_HOME="$HOME/.config"
  64.   fi
  65.  
  66.   if [ -z "$XDG_DATA_HOME" ]; then
  67.     export XDG_DATA_HOME="$HOME/.local/share"
  68.   fi
  69.  
  70.   export XDG_CACHE_HOME=$HOME/.cache
  71.    # Ensure the existance of the user applications folder
  72.   USER_APPS_DIR="$XDG_DATA_HOME/applications"
  73.   mkdir -p "$USER_APPS_DIR"
  74.  
  75.   # Ensure the existance of openbox config file
  76.   OPENBOX_CONF_DIR="$XDG_CONFIG_HOME/openbox"
  77.   if [ ! -f "$OPENBOX_CONF_DIR/lxde-rc.xml" ]; then
  78.     mkdir -p "$OPENBOX_CONF_DIR"
  79.     cp /etc/xdg/openbox/LXDE/rc.xml "$OPENBOX_CONF_DIR/lxde-rc.xml"
  80.   fi
  81.   # Ensure the existance of the 'Desktop' folder
  82.   if [ -e "$XDG_CONFIG_HOME/user-dirs.dirs" ]; then
  83.     . "$XDG_CONFIG_HOME/user-dirs.dirs"
  84.   else
  85.     XDG_DESKTOP_DIR="$HOME/Desktop"
  86.   fi
  87.   mkdir -p "$XDG_DESKTOP_DIR"
  88.   export XDG_DATA_DIRS="/usr/share:/usr/local/share:$HOME/.local/share"
  89.  
  90.  
  91.  
  92. }
  93. merge_xorg_resources(){
  94.  
  95.   userresources=$HOME/.Xresources
  96.   usermodmap=$HOME/.Xmodmap
  97.   sysresources=/usr/lib/X11/xinit/Xresources
  98.   sysmodmap=/usr/lib/X11/xinit/.Xmodmap
  99.  
  100.  
  101.   [ -z "$HOME" ] && set_home
  102.   # merge in defaults and keymaps
  103.  
  104.   if [ -f $sysresources ]; then
  105.     xrdb -merge -nocpp $sysresources
  106.   fi
  107.  
  108.   if [ -f $sysmodmap ]; then
  109.     xmodmap $sysmodmap
  110.   fi
  111.  
  112.   if [ -f $userresources ]; then
  113.     xrdb -merge -nocpp $userresources
  114.   fi
  115.   #100501 if full nvidia pkg installed, it has a gui config app...
  116.   [ -f $HOME/.nvidia-settings-rc ] && nvidia-settings --load-config-only
  117.  
  118.   [ -f $HOME/.xgamma-gamma ] && /bin/sh $HOME/.xgamma-gamma #100215 see /usr/sbin/xgamma-gui.
  119.  
  120.   if [ -f $usermodmap ]; then
  121.     xmodmap $usermodmap
  122.   fi
  123. }
  124. do_xrand_setup(){
  125.       #v1.0.7 set by xrandrshell, part of xorg wizard... v3.99...
  126.   if [ -f /etc/xrandrindex ];then
  127.     #v3.99 workround for dual monitors, 'head -n 1'....
  128.     XRANDRDEFAULT="$(xrandr -q | grep '\*' | tr -s ' ' | grep '^ [0-9]' | cut -f 2,3 -d ' ' | cut -f 1 -d '*' | tr ' ' '@' | head -n 1)" #130202 return 1024x768@60.0
  129.     XRANDRINDEX="`cat /etc/xrandrindex`" #v3.99 XRANDRINDEX now is XxY resolution. #130202 now vertxhoriz@freq (refer quicksetup).
  130.     #but do not switch if default is already this resolution....
  131.     if [ "$XRANDRINDEX" = "$XRANDRDEFAULT" ];then
  132.       rm -f /etc/xrandrindex
  133.     else
  134.       echo "$XRANDRINDEX"|grep -q "@"
  135.       case $? in
  136.       1)NEW_XY="$XRANDRINDEX"
  137.         xrandr -s $NEW_XY #131124 (see quicksetup)
  138.         ;;
  139.       *)NEW_XY="$(echo -n "$XRANDRINDEX" | cut -f 1 -d '@')" #130202
  140.         NEW_VFREQ="$(echo -n "$XRANDRINDEX" | cut -f 2 -d '@')" #130202
  141.         xrandr -s $NEW_XY -r $NEW_VFREQ #130202
  142.         ;;
  143.       esac
  144.     fi
  145.   fi
  146. }
  147. set_x_items(){
  148.   [ -z "$HOME" ] && set_home
  149.   if [ -f $HOME/.xset.sh ];then
  150.     #this is created by /usr/bin/pupx...
  151.     eval "$HOME/.xset.sh"
  152.   else
  153.     ##Xorg has it's own fontpath settings in /etc/X11/xorg.conf...
  154.     #if [ "`readlink /usr/bin/X`" != "Xorg" ];then
  155.     # #xset fp+ /usr/lib/X11/fonts/Type1/
  156.     # #xset fp+ /usr/lib/X11/fonts/TTF/
  157.     # xset fp+ /usr/share/fonts/default/Type1/
  158.     # xset fp+ /usr/share/fonts/default/TTF/
  159.     #fi
  160.     xset s 600 600 s blank
  161.   fi
  162.  
  163.   #v1.0.7 also see /etc/rc.d/rc.local0
  164.   if [ -f $HOME/.fonts/fonts.dir ];then
  165.     xset fp+ $HOME/.fonts/
  166.   fi
  167.   [ -f /usr/bin/xsetroot ] && xsetroot -cursor_name top_left_arrow 
  168.   ##v2.01 hide cursor when not moving... (setup in /usr/sbin/input-wizard)
  169.   #if [ -f /etc/mousehide ];then
  170.   # IDLETIME="`cat /etc/mousehide | cut -f 1 -d ','`"
  171.   # [ ! "$IDLETIME" = "0" ] && unclutter -idle $IDLETIME &
  172.   #fi
  173. }
  174. xinit_misc(){
  175.    #TODO maybe run check to see if this is already running
  176.    /sbin/pup_event_frontend_d & #130525 moved down.
  177.  
  178.   #v2.0.0
  179.   /usr/sbin/delayedrun &
  180. }
  181. start_desktop_if_no_autostart(){
  182.   case "$WINDOW_MANAGER" in
  183.   lxde*) ;;
  184.   *)
  185.     [ "$desktop" = "" ] && desktop=rox
  186.     case $desktop in
  187.     pcmanfm) pcmanfm --desktop & ;;
  188.     rox)
  189.       #relocates right-side icons to actual right-side of screen...
  190.       #v4.01 BK daemon to handle kernel uevents...
  191.       echo '' > /var/local/pup_event_icon_change_flag
  192.       /sbin/clean_desk_icons #v4.02 tidy up drive icons first.
  193.       NEEDRESHAPE='yes'
  194.       [ -f /usr/share/backgrounds_original/ORIGINAL-default.jpg ] && NEEDRESHAPE='no'
  195.       [ -f /usr/share/backgrounds_original/ORIGINAL-default.png ] && NEEDRESHAPE='no'
  196.       [ "$NEEDRESHAPE" = "yes" ] && /usr/sbin/background_reshape
  197.       /usr/sbin/fixPuppyPin $HOME/ROX-Filer/PuppyPin #v1.0.7
  198.  
  199.       sleep 1 # let the dust settle
  200.  
  201.       if [ -f $HOME/Choices/ROX-Filer/PuppyPan1 ];then
  202.         maybe_su $USER -p -c "roxfiler -p $HOME/Choices/ROX-Filer/PuppyPin -r $HOME/Choices/ROX-Filer/PuppyPan1"
  203.       else
  204.         maybe_su $USER -p -c "roxfiler -p $HOME/Choices/ROX-Filer/PuppyPin"
  205.       fi
  206.       ;;
  207.     esac
  208.     ;;
  209.   esac 
  210. }
  211. launch_wm(){
  212.   if [[ "$WINDOW_MANAGER"  = lxde* ]]; then
  213.     xprop -root -remove _NET_NUMBER_OF_DESKTOPS -remove _NET_DESKTOP_NAMES -remove _NET_CURRENT_DESKTOP 2> /dev/null  
  214.     # Enable GTK+2 integration for OpenOffice.org, if available.
  215.     export SAL_USE_VCLPLUGIN=gtk
  216.     if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS"; then
  217.       if test -z "$XDG_RUNTIME_DIR" -o ! -S "$XDG_RUNTIME_DIR/bus" -o ! -O "$XDG_RUNTIME_DIR/bus"; then
  218.         eval "$(dbus-launch --sh-syntax --exit-with-session)"
  219.       fi
  220.     fi  
  221.     export XDG_MENU_PREFIX="lxde-"
  222.     export XDG_CURRENT_DESKTOP="LXDE"
  223.  
  224.     # Start the LXDE session
  225.     #exec su --group=$GROUP -c '/usr/bin/lxsession -s LXDE -e LXDE' - $USER  
  226.     maybe_su_exec $USER -p -c '/usr/bin/lxsession -s LXDE -e LXDE'
  227.   else
  228.     #EXEC="exec ck-launch-session dbus-launch --sh-syntax --exit-with-session"
  229.     #EXEC="exec su --group=$GROUP -c 'dbus-launch --sh-syntax --exit-with-session'"
  230.  
  231.      
  232.      
  233.     case "$WINDOW_MANAGER" in
  234.       openbox|lxde*|icewm*|xfce4|compiz|karmen|dwm|fluxbox*|razor*|mate*)
  235.         WM_CMD="${WINDOW_MANAGER%-session}-session" ;;
  236.       enlightenment)
  237.         WM_CMD="enlightenment_start" ;;
  238.       kde)  
  239.         WM_CMD="startkde" ;;
  240.       lxqt)
  241.         WM_CMD="startlxqt" ;;
  242.       *)  
  243.         WM_CMD="$WINDOW_MANAGER"
  244.         ;;
  245.        
  246.     esac  
  247.     EXEC="maybe_su_exec $USER -p -c"
  248.     CMD="dbus-launch --sh-syntax --exit-with-session $WM_CMD"
  249.     LOG="/dev/null" ; X=$LOG ; ERR=$X    
  250.     $EXEC "$CMD" #2>>$ERR >>$X
  251.   fi
  252. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement