Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set_ids(){
- uid1=`id -u -r`
- euid1=`id -u`
- [ -z "$uid" ] && uid=${uid:-$uid1}
- [ -z "$euid" ] && euid=${euid:-$euid1}
- }
- set_home(){
- set_ids
- USER=${USER:-`id -nu "$uid"`}
- HOME=`eval 'echo ~'"$USER"`
- }
- maybe_su(){
- set_ids
- if [ $euid1 -eq 0 ] && \
- [ $uid1 -ne $uid ] ; then
- su "$@"
- else
- i=1
- for x in "$@"; do
- if [ "$x" = "-c" ]; then
- next=$((i + 1))
- A_CMD=${@:$next:1}
- break
- fi
- let "i++"
- done
- eval "$A_CMD"
- fi
- }
- maybe_su_exec(){
- if [ $euid1 -eq 0 ] && \
- [ $uid1 -ne $uid ] ; then
- exec su "$@"
- else
- i=1
- for x in "$@"; do
- if [ "$x" = "-c" ]; then
- next=$((i + 1))
- A_CMD=${@:$next:1}
- break
- fi
- let "i++"
- done
- exec $A_CMD
- fi
- }
- config_xdg_env(){
- [ -z "$HOME" ] && set_home
- export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
- if [ -f "$XDG_CONFIG_HOME"/slitaz/applications.conf ]; then
- apps_conf="$XDG_CONFIG_HOME"/slitaz/applications.conf
- elif [ -f "/etc/skel/.config/slitaz/applications.conf" ]; then
- apps_conf="/etc/skel/.config/slitaz/applications.conf"
- elif [ -f "/etc/slitaz/applications.conf" ]; then
- apps_conf="/etc/slitaz/applications.conf"
- fi
- . "$apps_conf"
- if [ -z "$XDG_CONFIG_HOME" ]; then
- export XDG_CONFIG_HOME="$HOME/.config"
- fi
- if [ -z "$XDG_DATA_HOME" ]; then
- export XDG_DATA_HOME="$HOME/.local/share"
- fi
- export XDG_CACHE_HOME=$HOME/.cache
- # Ensure the existance of the user applications folder
- USER_APPS_DIR="$XDG_DATA_HOME/applications"
- mkdir -p "$USER_APPS_DIR"
- # Ensure the existance of openbox config file
- OPENBOX_CONF_DIR="$XDG_CONFIG_HOME/openbox"
- if [ ! -f "$OPENBOX_CONF_DIR/lxde-rc.xml" ]; then
- mkdir -p "$OPENBOX_CONF_DIR"
- cp /etc/xdg/openbox/LXDE/rc.xml "$OPENBOX_CONF_DIR/lxde-rc.xml"
- fi
- # Ensure the existance of the 'Desktop' folder
- if [ -e "$XDG_CONFIG_HOME/user-dirs.dirs" ]; then
- . "$XDG_CONFIG_HOME/user-dirs.dirs"
- else
- XDG_DESKTOP_DIR="$HOME/Desktop"
- fi
- mkdir -p "$XDG_DESKTOP_DIR"
- export XDG_DATA_DIRS="/usr/share:/usr/local/share:$HOME/.local/share"
- }
- merge_xorg_resources(){
- userresources=$HOME/.Xresources
- usermodmap=$HOME/.Xmodmap
- sysresources=/usr/lib/X11/xinit/Xresources
- sysmodmap=/usr/lib/X11/xinit/.Xmodmap
- [ -z "$HOME" ] && set_home
- # merge in defaults and keymaps
- if [ -f $sysresources ]; then
- xrdb -merge -nocpp $sysresources
- fi
- if [ -f $sysmodmap ]; then
- xmodmap $sysmodmap
- fi
- if [ -f $userresources ]; then
- xrdb -merge -nocpp $userresources
- fi
- #100501 if full nvidia pkg installed, it has a gui config app...
- [ -f $HOME/.nvidia-settings-rc ] && nvidia-settings --load-config-only
- [ -f $HOME/.xgamma-gamma ] && /bin/sh $HOME/.xgamma-gamma #100215 see /usr/sbin/xgamma-gui.
- if [ -f $usermodmap ]; then
- xmodmap $usermodmap
- fi
- }
- do_xrand_setup(){
- #v1.0.7 set by xrandrshell, part of xorg wizard... v3.99...
- if [ -f /etc/xrandrindex ];then
- #v3.99 workround for dual monitors, 'head -n 1'....
- 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
- XRANDRINDEX="`cat /etc/xrandrindex`" #v3.99 XRANDRINDEX now is XxY resolution. #130202 now vertxhoriz@freq (refer quicksetup).
- #but do not switch if default is already this resolution....
- if [ "$XRANDRINDEX" = "$XRANDRDEFAULT" ];then
- rm -f /etc/xrandrindex
- else
- echo "$XRANDRINDEX"|grep -q "@"
- case $? in
- 1)NEW_XY="$XRANDRINDEX"
- xrandr -s $NEW_XY #131124 (see quicksetup)
- ;;
- *)NEW_XY="$(echo -n "$XRANDRINDEX" | cut -f 1 -d '@')" #130202
- NEW_VFREQ="$(echo -n "$XRANDRINDEX" | cut -f 2 -d '@')" #130202
- xrandr -s $NEW_XY -r $NEW_VFREQ #130202
- ;;
- esac
- fi
- fi
- }
- set_x_items(){
- [ -z "$HOME" ] && set_home
- if [ -f $HOME/.xset.sh ];then
- #this is created by /usr/bin/pupx...
- eval "$HOME/.xset.sh"
- else
- ##Xorg has it's own fontpath settings in /etc/X11/xorg.conf...
- #if [ "`readlink /usr/bin/X`" != "Xorg" ];then
- # #xset fp+ /usr/lib/X11/fonts/Type1/
- # #xset fp+ /usr/lib/X11/fonts/TTF/
- # xset fp+ /usr/share/fonts/default/Type1/
- # xset fp+ /usr/share/fonts/default/TTF/
- #fi
- xset s 600 600 s blank
- fi
- #v1.0.7 also see /etc/rc.d/rc.local0
- if [ -f $HOME/.fonts/fonts.dir ];then
- xset fp+ $HOME/.fonts/
- fi
- [ -f /usr/bin/xsetroot ] && xsetroot -cursor_name top_left_arrow
- ##v2.01 hide cursor when not moving... (setup in /usr/sbin/input-wizard)
- #if [ -f /etc/mousehide ];then
- # IDLETIME="`cat /etc/mousehide | cut -f 1 -d ','`"
- # [ ! "$IDLETIME" = "0" ] && unclutter -idle $IDLETIME &
- #fi
- }
- xinit_misc(){
- #TODO maybe run check to see if this is already running
- /sbin/pup_event_frontend_d & #130525 moved down.
- #v2.0.0
- /usr/sbin/delayedrun &
- }
- start_desktop_if_no_autostart(){
- case "$WINDOW_MANAGER" in
- lxde*) ;;
- *)
- [ "$desktop" = "" ] && desktop=rox
- case $desktop in
- pcmanfm) pcmanfm --desktop & ;;
- rox)
- #relocates right-side icons to actual right-side of screen...
- #v4.01 BK daemon to handle kernel uevents...
- echo '' > /var/local/pup_event_icon_change_flag
- /sbin/clean_desk_icons #v4.02 tidy up drive icons first.
- NEEDRESHAPE='yes'
- [ -f /usr/share/backgrounds_original/ORIGINAL-default.jpg ] && NEEDRESHAPE='no'
- [ -f /usr/share/backgrounds_original/ORIGINAL-default.png ] && NEEDRESHAPE='no'
- [ "$NEEDRESHAPE" = "yes" ] && /usr/sbin/background_reshape
- /usr/sbin/fixPuppyPin $HOME/ROX-Filer/PuppyPin #v1.0.7
- sleep 1 # let the dust settle
- if [ -f $HOME/Choices/ROX-Filer/PuppyPan1 ];then
- maybe_su $USER -p -c "roxfiler -p $HOME/Choices/ROX-Filer/PuppyPin -r $HOME/Choices/ROX-Filer/PuppyPan1"
- else
- maybe_su $USER -p -c "roxfiler -p $HOME/Choices/ROX-Filer/PuppyPin"
- fi
- ;;
- esac
- ;;
- esac
- }
- launch_wm(){
- if [[ "$WINDOW_MANAGER" = lxde* ]]; then
- xprop -root -remove _NET_NUMBER_OF_DESKTOPS -remove _NET_DESKTOP_NAMES -remove _NET_CURRENT_DESKTOP 2> /dev/null
- # Enable GTK+2 integration for OpenOffice.org, if available.
- export SAL_USE_VCLPLUGIN=gtk
- if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS"; then
- if test -z "$XDG_RUNTIME_DIR" -o ! -S "$XDG_RUNTIME_DIR/bus" -o ! -O "$XDG_RUNTIME_DIR/bus"; then
- eval "$(dbus-launch --sh-syntax --exit-with-session)"
- fi
- fi
- export XDG_MENU_PREFIX="lxde-"
- export XDG_CURRENT_DESKTOP="LXDE"
- # Start the LXDE session
- #exec su --group=$GROUP -c '/usr/bin/lxsession -s LXDE -e LXDE' - $USER
- maybe_su_exec $USER -p -c '/usr/bin/lxsession -s LXDE -e LXDE'
- else
- #EXEC="exec ck-launch-session dbus-launch --sh-syntax --exit-with-session"
- #EXEC="exec su --group=$GROUP -c 'dbus-launch --sh-syntax --exit-with-session'"
- case "$WINDOW_MANAGER" in
- openbox|lxde*|icewm*|xfce4|compiz|karmen|dwm|fluxbox*|razor*|mate*)
- WM_CMD="${WINDOW_MANAGER%-session}-session" ;;
- enlightenment)
- WM_CMD="enlightenment_start" ;;
- kde)
- WM_CMD="startkde" ;;
- lxqt)
- WM_CMD="startlxqt" ;;
- *)
- WM_CMD="$WINDOW_MANAGER"
- ;;
- esac
- EXEC="maybe_su_exec $USER -p -c"
- CMD="dbus-launch --sh-syntax --exit-with-session $WM_CMD"
- LOG="/dev/null" ; X=$LOG ; ERR=$X
- $EXEC "$CMD" #2>>$ERR >>$X
- fi
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement