#!/bin/sh # Copyright 1999, 2002, 2012 Patrick Volkerding, Moorhead, Minnesota USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # In the genuine installer we are possibly called by setup.xwmconfig so: # chroot $T_PX /bin/bash /usr/bin/xwmconfig. But this prevent access to the # installer from here. To avoid that now setup.xwmconfig calls us so: # /usr/lib64/config/xwmconfig $T_PX # But then, we need to to prefix most paths here with $T_PX. - Didier Spaier T_PX=$1 export TEXTDOMAIN=slint . gettext.sh # First, let's bail if our being here doesn't make sense: if [ ! -d $T_PX/etc/X11/xinit ]; then exit fi if [ "`cd $T_PX/etc/X11/xinit ; echo *.*`" = '*.*' ]; then exit fi if [ "$USER" = "root" ]; then TMP=$T_PX/var/log/setup/tmp else TMP=$T_PX/$HOME/.xwmconfig fi if [ ! -d $TMP ]; then mkdir -p $TMP chmod 700 $TMP fi # Do we already have an existing default? # If yes pre select it # else pre select fvwm2 unset PRESELECT if [ -L $T_PX/etc/X11/xinit/xinitrc ]; then CURRENT="`/bin/ls -l $T_PX/etc/X11/xinit/xinitrc | cut -f 2 -d '>' | cut -b2-`" PRESELECT=" --default-item $CURRENT " elif [ -r $T_PX/etc/X11/xinit/xinitrc.fvwm2 ]; then PRESELECT=" --default-item xinitrc.fvwm2" fi # Figure out who we are and set up some background information: if [ "$USER" = "root" ]; then BACKTITLE="--backtitle \"`gettext \"Setting system-wide default window manager in /etc/X11/xinit/\"`\"" else BACKTITLE="--backtitle \"`eval_gettext \"Setting default window manager in \\\$HOME/.xinitrc and \\\$HOME/.xsession\"`\"" fi # This stops --backtitle from cluttering the initial install: if [ ! -r /proc/kcore ]; then BACKTITLE="" fi # Remove any previous script: rm -f $TMP/tmpscript.sh # Add the top of the script: if [ -r $T_PX/etc/X11/xinit/xinitrc.gnome -a -r $T_PX/etc/X11/xinit/xinitrc.kde ]; then echo "#!/bin/sh dialog --visit-items $BACKTITLE --title \"" >> $TMP/tmpscript.sh gettext "SELECT DEFAULT WINDOW MANAGER FOR X" >> $TMP/tmpscript.sh echo -n "\" $PRESELECT --menu \"" >> $TMP/tmpscript.sh gettext "Please select the default window manager to use with the X Window \ System. This will define the style of graphical user interface \ the computer uses. KDE and GNOME provide the most features. People \ with Windows or MacOS experience will find either one easy to use. \ Other window managers are easier on system \ resources, or provide other unique features." >> $TMP/tmpscript.sh echo -n '" 12 80 0 ' >> $TMP/tmpscript.sh elif [ -r $T_PX/etc/X11/xinit/xinitrc.kde ]; then echo -n "#!/bin/sh dialog --visit-items $BACKTITLE --title \"" >> $TMP/tmpscript.sh gettext "SELECT DEFAULT WINDOW MANAGER FOR X" >> $TMP/tmpscript.sh echo -n "\" $PRESELECT --menu \"" >> $TMP/tmpscript.sh gettext "Please select the default window manager to use with the X Window \ System. This will define the style of graphical user interface \ the computer uses. KDE provides the most features, and people \ with Windows or MacOS experience will find it easy to use. \ Other window managers are easier on system \ resources, or provide other unique features." >> $TMP/tmpscript.sh echo -n '" 12 80 0 ' >> $TMP/tmpscript.sh elif [ -r $T_PX/etc/X11/xinit/xinitrc.xfce ]; then echo -n "#!/bin/sh dialog --visit-items $BACKTITLE --title \"" >> $TMP/tmpscript.sh gettext "SELECT DEFAULT WINDOW MANAGER FOR X" >> $TMP/tmpscript.sh echo -n "\" $PRESELECT --menu \"" >> $TMP/tmpscript.sh gettext "Please select the default window manager to use with the X Window \ System. This will define the style of graphical user interface \ the computer uses. XFce provides the most features, and people \ with Windows or MacOS experience will find it easy to use. \ Other window managers are easier on system \ resources, or provide other unique features." >> $TMP/tmpscript.sh echo -n '" 12 80 0 ' >> $TMP/tmpscript.sh else echo -n "#!/bin/sh dialog --visit-items $BACKTITLE --title \"" >> $TMP/tmpscript.sh gettext "SELECT DEFAULT WINDOW MANAGER FOR X" >> $TMP/tmpscript.sh echo -n "\" $PRESELECT --menu \"" >> $TMP/tmpscript.sh gettext "Please select the default window manager to use with the X Window \ System. This will define the style of graphical user interface \ the computer uses." >> $TMP/tmpscript.sh echo -n '" 12 80 0 ' >> $TMP/tmpscript.sh fi # Add KDE as the first and default entry: if [ -r $T_PX/etc/X11/xinit/xinitrc.kde ]; then echo "\"xinitrc.kde\" \"`gettext "KDE: K Desktop Environment"`\" \\" >> $TMP/tmpscript.sh fi # Then, we add GNOME: if [ -r $T_PX/etc/X11/xinit/xinitrc.gnome ]; then echo "\"xinitrc.gnome\" \"`gettext "GNU Network Object Model Environment"`\" \\" >> $TMP/tmpscript.sh fi # Add XFce: if [ -r $T_PX/etc/X11/xinit/xinitrc.xfce ]; then echo "\"xinitrc.xfce\" \"`gettext "The Cholesterol Free Desktop Environment"`\" \\" >> $TMP/tmpscript.sh fi # Add Enlightenment16: if [ -r $T_PX/etc/X11/xinit/xinitrc.e16 ]; then echo "\"xinitrc.e16\" \"`gettext "The Enlightenment 16 window manager"`\" \\" >> $TMP/tmpscript.sh fi # Add Enlightenment17: if [ -r $T_PX/etc/X11/xinit/xinitrc.e16 ]; then echo "\"xinitrc.enlightenment17\" \"`gettext "The Enlightenment 17 window manager"`\" \\" >> $TMP/tmpscript.sh fi # Add Fluxbox: if [ -r $T_PX/etc/X11/xinit/xinitrc.fluxbox ]; then echo "\"xinitrc.fluxbox\" \"`gettext "The fluxbox window manager"`\" \\" >> $TMP/tmpscript.sh fi # Add Blackbox: if [ -r $T_PX/etc/X11/xinit/xinitrc.blackbox ]; then echo "\"xinitrc.blackbox\" \"`gettext "The blackbox window manager"`\" \\" >> $TMP/tmpscript.sh fi # Add WindowMaker: if [ -r $T_PX/etc/X11/xinit/xinitrc.wmaker ]; then echo "\"xinitrc.wmaker\" \"`gettext "WindowMaker"`\" \\" >> $TMP/tmpscript.sh fi # Add FVWM2: if [ -r $T_PX/etc/X11/xinit/xinitrc.fvwm2 ]; then echo "\"xinitrc.fvwm2\" \"`gettext "F(?) Virtual Window Manager"`\" \\" >> $TMP/tmpscript.sh fi # Add icewm: if [ -r $T_PX/etc/X11/xinit/xinitrc.icewm ]; then echo "\"xinitrc.icewm\" \"`gettext "ICE Window Manager"`\" \\" >> $TMP/tmpscript.sh fi # Add mate: if [ -r $T_PX/etc/X11/xinit/xinitrc.mate ]; then echo "\"xinitrc.mate\" \"`gettext "The Mate desktop"`\" \\" >> $TMP/tmpscript.sh fi # Add twm: if [ -r $T_PX/etc/X11/xinit/xinitrc.twm ]; then echo "\"xinitrc.twm\" \"`gettext "The Tab Window Manager"`\" \\" >> $TMP/tmpscript.sh fi # Add AfterStep: if [ -r $T_PX/etc/X11/xinit/xinitrc.afterstep ]; then echo "\"xinitrc.afterstep\" \"`gettext "The AfterStep Window Menager"`\" \\" >> $TMP/tmpscript.sh fi # Add Awesome: if [ -r $T_PX/etc/X11/xinit/xinitrc.awesome ]; then echo "\"xinitrc.awesome\" \"`gettext "The Mate desktop"`\" \\" >> $TMP/tmpscript.sh fi # Now, add support for the other window managers: ( cd $T_PX/etc/X11/xinit for file in xinitrc.* ; do if [ ! "$file" = "xinitrc.kde" -a ! "$file" = "xinitrc.gnome" \ -a ! "$file" = "xinitrc.e16" -a ! "$file" = "xinitrc.wmaker" \ -a ! "$file" = "xinitrc.fvwm2" -a ! "$file" = "xinitrc.enlightenment"\ -a ! "$file" = "xinitrc.icewm" -a ! "$file" = "xinitrc.twm" \ -a ! "$file" = "xinitrc.xfce" -a ! "$file" = "xinitrc.awesome" \ -a ! "$file" = "xinitrc.blackbox" -a ! "$file" = "xinitrc.fluxbox" \ -a ! "$file" = "xinitrc.mate" -a ! "$file" = "xinitrc.afterstep" ]; then echo "\"$file\" \"$file\" \\" >> $TMP/tmpscript.sh fi done ) # Then, the tail end: cat << EOF >> $TMP/tmpscript.sh 2> $TMP/output if [ ! \$? = 0 ]; then rm -f $TMP/output gettext "Canceled." echo exit fi EOF sh $TMP/tmpscript.sh if [ ! -r $TMP/output ]; then rm -f $TMP/tmpscript.sh exit fi OUTPUT=`cat $TMP/output` # If xwmconfig is run by root, it changes the system-wide default for users # that do not have a $HOME/.xinitrc: if [ "$USER" = "root" ]; then if [ -r $T_PX/etc/X11/xinit/$OUTPUT ]; then ( cd $T_PX/etc/X11/xinit ; rm -f xinitrc ; ln -sf $OUTPUT xinitrc ) TMPFILE=$(mktemp) LXDM=/etc/lxdm/lxdm.conf case $OUTPUT in xinitrc.kde) sed /^session/s:.*:session=/usr/bin/startkde: $LXDM > $TMPFILE; mv $TMPFILE $LXDM;; xinitrc.gnome) sed /^session/s:.*:session=/usr/bin/gnome-session: $LXDM > $TMPFILE; mv $TMPFILE $LXDM;; xinitrc.xfce) sed /^session/s:.*:session=/usr/bin/startxfce4: $LXDM > $TMPFILE; mv $TMPFILE $LXDM;; xinitrc.fvwm2) sed /^session/s:.*:session=/usr/bin/startfvwm2: $LXDM > $TMPFILE; mv $TMPFILE $LXDM;; xinitrc.icewm) sed /^session/s:.*:session=/usr/bin/icewm-session: $LXDM > $TMPFILE; mv $TMPFILE $LXDM;; xinitrc.mate) sed /^session/s:.*:session=/usr/bin/mate-session: $LXDM > $TMPFILE; mv $TMPFILE $LXDM;; xinitrc.wmaker) sed /^session/s:.*:session=/usr/bin/wmaker: $LXDM > $TMPFILE; mv $TMPFILE $LXDM;; xinitrc.e16) sed /^session/s:.*:session=/usr/share/e16/misc/starte16: $LXDM > $TMPFILE; mv $TMPFILE $LXDM;; xinitrc.enlightenment) sed /^session/s:.*:session=/usr/bin/enlightenment_start: $LXDM > $TMPFILE; mv $TMPFILE $LXDM;; xinitrc.blackbox) sed /^session/s:.*:session=/usr/bin/startblackbox: $LXDM > $TMPFILE; mv $TMPFILE $LXDM;; xinitrc.fluxbox) sed /^session/s:.*:session=/usr/bin/startfluxbox: $LXDM > $TMPFILE; mv $TMPFILE $LXDM;; xinitrc.twm) sed /^session/s:.*:session=/usr/bin/starttwm: $LXDM > $TMPFILE; mv $TMPFILE $LXDM;; xinitrc.awesome) sed /^session/s:.*:session=/usr/bin/awesome: $LXDM > $TMPFILE; mv $TMPFILE $LXDM;; # TODO: provide a .desktop for AfterStep # xinitrc.afterstep) # sed /^session/s:.*:session=/usr/bin/afterstep: $LXDM > $TMPFILE; mv $TMPFILE $LXDM;; *) sed /^session/s:.*:session=/usr/bin/startfluxbox: $LXDM > $TMPFILE; mv $TMPFILE $LXDM;; esac fi fi # Also set up a new $HOME/.xinitrc and $HOME/.xinitrc: if [ -r /etc/X11/xinit/$OUTPUT -a ! "$HOME" = "/" ]; then if [ -r $HOME/.xinitrc ]; then rm -f $HOME/.xinitrc-backup mv $HOME/.xinitrc $HOME/.xinitrc-backup fi cat /etc/X11/xinit/$OUTPUT > $HOME/.xinitrc if [ -r $HOME/.xsession ]; then rm -f $HOME/.xsession-backup mv $HOME/.xsession $HOME/.xsession-backup fi cat /etc/X11/xinit/$OUTPUT > $HOME/.xsession chmod 755 $HOME/.xsession fi rm -f $TMP/tmpscript.sh $TMP/output