#!/bin/sh # # nicofo - http://nicofo.tuxfamily.org # Automatic installation and configuration of xgl for GNOME, KDE and XFCE # # English version. Original is at # http://nicofo.tuxfamily.org/scripts/xgl/installXGL # # 20/01/07 - version 1 # 06/02/07 - version 2 Mis à jour pour pouvoir faire des updates # 08/03/07 - version 3 Possibilité de désinstaller # 01/04/07 - version 4 Architectures x86_64 # 01/06/07 - version 5 Nouvelle version de XGL pour FC6 : # utilise les versions officielles de compiz et beryl # 21/06/07 - version 6 N'utilise plus xgl-info # 22/06/07 - version 7 Pour Fedora 7 également # 09/08/07 - version 8 Compiz-fusion # 06/11/07 - version 8.2 testRoot() { if [ $(id -u) -ne 0 ]; then echo -e "The installation and configuration of XGL must be run as \033[1mroot\033[0m." exit 1 fi } #supprime les anciens fichiers de config clearOldVersion() { rm -f /usr/sbin/xgl-info rm -f /etc/xgl/xgl-hardware-list rmdir /etc/xgl 2>/dev/null } msg() { if [ $# -ge 2 ] && [ "$1" = "-n" ]; then echo -en "\n\033[1;34m$2\033[0m" else echo -e "\n\033[1;34m$1\033[0m" fi } #Désinstalle compiz removeCompiz() { if [ -f /usr/bin/gset-compiz ]; then rpm -e gset-compiz rmdir /usr/lib/compiz 2>/dev/null #version 64 bits fi yum remove compiz } #Désinstalle compiz-fusion removeFusion() { rm /etc/yum.repos.d/kagesenshi.repo [ -f /usr/bin/beryl ] && msg "The version of emerald compatible with Beryl will be reinstalled next..." yum remove compiz\* fusion-icon\* emerald\* libcompizconfig [ -f /usr/bin/beryl ] && yum install emerald-themes emerald } #Désinstalle beryl removeBeryl() { yum remove beryl\* } #Demande s'il faut désinstaller compiz (fusion) et beryl removeCompizBeryl() { [ $# -eq 0 ] && seq=0 || seq=$1 #Supprimer Compiz (fusion) : if [ -f /usr/bin/compiz ]; then seq=$(($seq+1)) rpm -q compiz-fusion-plugins-main>/dev/null && add="-fusion" msg -n "$seq) Do you want to remove Compiz$add [y/N] ? " read res if [ "$res" == "y" ] || [ "$res" == "Y" ]; then [ "$add" = "-fusion" ] && ( removeFusion || [ 1 ] ) || removeCompiz fi fi #Supprimer Beryl : if [ -f /usr/bin/beryl ]; then seq=$(($seq+1)) msg -n "$seq) Do you want to remove Beryl [y/N] ? " read res if [ "$res" == "y" ] || [ "$res" == "Y" ] ;then removeBeryl fi fi } #Demande s'il faut installer compiz (fusion) et beryl installCompizBeryl() { rpm -q compiz-fusion-plugins-main>/dev/null [ -f /usr/bin/compiz -a $? -eq 0 ] && F=1 || F=0 [ -f /usr/bin/compiz -a $F -eq 0 ] && C=1 || C=0 #1 ==> compiz déjà installé [ -f /usr/bin/beryl ] && B=1 || B=0 IC=0 #1=install compiz IF=0 IB=0 RC=0 #1=remove compiz RF=0 echo -en "\n\033[1m[1/2] Compiz - Compiz-fusion (Fedora 7 only)\033[0m" if [ $B -eq 1 ] && [ $F -eq 0 ]; then echo -en "\n\033[4mRemark\033[0m: Beryl is already installed. If you decide to install Compiz-fusion, it\nwill remain possible to use Beryl provided that you use another window decorator\nthan emerald." fi if [ $C -eq 1 ] && [ $F -eq 0 ]; then msg -n "Do you want to replace Compiz with \033[31mCompiz-fusion\033[1;34m [Y/n] ? " read res [ ! "$res" == "n" ] && [ ! "$res" == "N" ] && IF=1 && RC=1 elif [ $C -eq 0 ] && [ $F -eq 1 ]; then msg -n "Do you want to replace Compiz-fusion with \033[31mCompiz\033[1;34m [y/N] ? " read res [ "$res" == "y" -o "$res" == "Y" ] && IC=1 && RF=1 else #ni compiz ni compiz-fusion installés msg -n "Do you want to install \033[31mCompiz-fusion\033[1;34m or \033[31mCompiz\033[1;34m ? Compiz-fusion [1] (default) Compiz [2] (nothing) [3] \r> " read res [ "$res" = 2 ] && IC=1 [ ! "$res" = 2 ] && [ ! "$res" = 3 ] && IF=1 fi echo -en "\n\033[1m[2/2] Beryl\033[0m" if [ $B -eq 1 ]; then msg "Beryl is already installed." else if [ $F -eq 1 ] && [ $RF -eq 0 ] || [ $IF -eq 1 ]; then echo -en "\n\033[4mRemark\033[0m: Compiz-fusion is already installed. If you decide to install Beryl as\nwell, you will have to use another window decorator than emerald for Beryl." fi msg -n "Do you want to install Beryl [Y/n] ? " read res [ ! "$res" == "n" ] && [ ! "$res" == "N" ] && IB=1 fi seq=0 #Désinstaller if [ $RC -eq 1 ]; then seq=$(($seq+1)) msg "$seq) Removing Compiz..." removeCompiz fi if [ $RF -eq 1 ]; then seq=$(($seq+1)) msg "$seq) Removing Compiz-fusion..." removeFusion fi #Installer KDE=0 GNOME=0 rpm -q kdebase >/dev/null && KDE=1 || GNOME=1 rpm -q gnome-session >/dev/null && GNOME=1 if [ $IF -eq 1 ]; then seq=$(($seq+1)) msg "$seq) Installation of Compiz-fusion..." wget http://devel.foss.org.my/~kagesenshi/repo/pub/kagesenshi.repo -O /etc/yum.repos.d/kagesenshi.repo fusion_com="compiz-fusion-plugins-main compiz-fusion-plugins-extra compizconfig-settings-manager emerald emerald-themes" [ $KDE -eq 1 ] && fusion_kde="compiz-kde fusion-icon-qt" [ $GNOME -eq 1 ] && fusion_gnome="compiz-gnome fusion-icon-gtk" yum install $fusion_com $fusion_kde $fusion_gnome #sed -i "s#icon = gtk.status_icon_new_from_icon_name('fusion-icon')#icon = gtk.status_icon_new_from_file('/usr/share/icons/hicolor/scalable/apps/fusion-icon.svg')#" /usr/share/fusion-icon/interface_gtk.py fi if [ $IC -eq 1 ]; then seq=$(($seq+1)) msg "$seq)Installation of Compiz..." yum install compiz fi IG=0 #install gset-compiz if [ -f /usr/bin/compiz ] && ! rpm -q compiz-fusion-plugins-main>/dev/null && [ ! -f /usr/bin/gset-compiz ]; then msg "Do you want to install 'gset-compiz' (FC5 version) which allows to configure\ncompiz ? [y/N]" read res [ "$(arch)" = "x86_64" ] && ARCH=x86_64 || ARCH=i386 [ "$res" == "y" -o "$res" == "Y" ] && rpm -Uhv http://nicofo.tuxfamily.org/scripts/xgl/gset-compiz/gset-compiz-0.3.3-1.$ARCH.rpm && IG=1 [ "$ARCH" = "x86_64" ] && [ -f /usr/bin/gset-compiz ] && mkdir /usr/lib/compiz #sinon bug en 64 bits fi if [ $IB -eq 1 ]; then seq=$(($seq+1)) msg "$seq) Installation of Beryl..." [ $KDE -eq 1 ] && beryl_kde="beryl-kde" [ $GNOME -eq 1 ] && beryl_gnome="beryl-gnome" yum install $beryl_kde $beryl_gnome fi #0 : installation OK [ $(($IF+$IC+$IB+$IG)) -eq 0 ] && return 1 || return 0 #1 : on a demandé de ne rien installer } if [ $# -ge 1 ]; then if [ $1 = "-r" ] || [ $1 = "--remove" ]; then testRoot #Déconfigurer XGL : msg "1) Removing configuration files... " wget http://nicofo.tuxfamily.org/scripts/xgl/xgl-settings.tar.gz -O xgl-settings.tar.gz tar -xzf xgl-settings.tar.gz configureXgl sh configureXgl -r rm -f configureXgl xgl-settings.tar.gz #Supprimer les RPM installés : msg "2) Uninstall XGL..." rpm -e xorg-x11-server-Xgl --noscripts clearOldVersion if [ -z "$(rpm -e glitz-glx glitz --test 2>&1)" ]; then rpm -e glitz-glx glitz fi seq=2 removeCompizBeryl $seq echo -e "\n\033[1mUninstallation finished.\033[0m" elif [ $1 = "-cb" ] || [ $1 = "-bc" ]; then testRoot installCompizBeryl elif [ $1 = "-rcb" ] || [ $1 = "-rbc" ]; then testRoot removeCompizBeryl else echo "Usage:" echo " $(basename $0) install and configure XGL / update XGL" echo " $(basename $0) -r|--remove uninstall XGL" echo " $(basename $0) -cb propose to install compiz(-fusion) and beryl" echo " $(basename $0) -rcb propose to remove compiz(-fusion) and beryl" fi exit 0 fi testRoot texte=( "Installation check" "Download of XGL" "Installation of XGL" "Configuration of XGL" "Installation of Compiz and Beryl" ) N=${#texte[*]} #nombre total d'étapes = nombre d'éléments dans $texte (ou : ${#texte[@]}) n=0 #étape actuelle (à partir de 0) #$etat = status de l'étape précédente #0=OK ; autre=KO ; -1=STOP ; -2=so (sans objet) etat=0 erreur="" avant="\033[2m" actuel="\033[1;5;33;42m" apres="\033[1;34m" normal="\033[m" ok="\033[1;32m[ OK ]\033[0m" ko="\033[1;31m[ KO ]\033[0m" so="\033[1;36m[Alrdy done]\033[0m" stop() { echo echo -e "\033[31m$erreur\033[0m" read -p "Installation cannot continue. Do you want to continue anyway [y/N] ? " res if [ ! "$res" == "y" ] && [ ! "$res" == "Y" ] ;then exit $n fi echo etat=1 erreur="" } menu() { #status : 0=OK ; autre=KO ; -1=STOP ; -2=so (sans objet) if [ $n -gt 0 ]; then status[$((n-1))]=$etat fi if [ $etat -eq -1 ]; then stop elif [ -n "$erreur" ]; then echo -e "\033[31m$erreur\033[0m" fi clear for i in $(seq 0 $(($N-1))); do if [ $i -lt $n ]; then echo -en $avant elif [ $i -eq $n ]; then echo -en $actuel else echo -en $apres fi echo -n "$(($i+1))) ${texte[$i]}" if [ $i -lt $n ]; then echo -en "\033[500C\033[15D$normal" #fin ligne if [ ${status[$i]} -eq 0 ]; then echo -e "$ok" elif [ ${status[$i]} -eq -2 ]; then echo -e "$so" else echo -e "$ko" fi else echo -e "$normal" fi done n=$(($n+1)) echo ; echo erreur="" etat=0 } #Vérif. de l'installation menu etat=-2 #détermination de la version de Fedora et de l'architecture ARCH=$(uname -m) [ ! "$ARCH" = "x86_64" ] && ARCH=i386 FED_VERSION=$(more /etc/fedora-release |sed "s/^.* \([0-9]\+\) (.*)$/\1/") [ -z $(echo $FED_VERSION |grep "^[0-9]\+$") ] && msg "Error while determining the version of Fedora" && exit echo "Version of Fedora : $FED_VERSION" echo "Architecture : $ARCH" if [ ! $FED_VERSION -ge 6 ]; then msg "This installation script of xgl is valid for a version of Fedora > 5." if [ $FED_VERSION -eq 5 ]; then msg -n "For Fedora 5, use \033[4minstallXGL_FC5_EN" msg "\thttp://nicofo.tuxfamily.org/scripts/xgl/installXGL_FC5_EN" fi exit fi if [ "$(rpm -q xorg-x11-server-Xgl)" = "xorg-x11-server-Xgl-1.1.99.1-3" ]; then msg "Removal of the old version of XGL\n\t(you do not need to remove Beryl) [ENTER]" read res wget http://nicofo.tuxfamily.org/scripts/xgl/installXGL_FC5_EN -O installXGL_old sh installXGL_old -r rm installXGL_old etat=0 fi for DEP in zenity xorg-x11-fonts-base ; do if ! rpm -q $DEP>/dev/null; then msg "Dependency installation: $DEP" yum install $DEP etat=0 fi done clearOldVersion #Téléchargement de XGL #version actuelle de XGL : version_xgl=$(rpm -q xorg-x11-server-Xgl) DJ_INST=$? #0 ==> déjà installé if [ $DJ_INST -eq 0 ]; then texte[$n]="Check for updates of XGL and download" fi menu #SITE_XGL="http://files.damaestro.us/xgl/" # (old FC6) #NOM_SETTINGS="Xgl-settings" # (old FC6) SITE_XGL="http://download.tuxfamily.org/fedoraxgl/$FED_VERSION/$ARCH/" #site des RPM NOM_SETTINGS="system-config-xselector" #nom du RPM de configuration wget $SITE_XGL -O xgl.html if [ $? -eq 0 ]; then # rpm_xgl=$(grep "xorg-x11-server-Xgl-[0-9][^\"]*.$ARCH.rpm" xgl.html -o|sort -ur|head -n 1) # rpm_xgl_set=$(grep "$NOM_SETTINGS-[0-9][^\"]*.noarch.rpm" xgl.html -o|sort -ur|head -n 1) # fonctionne pas si fichiers non triés sur le serveur : # rpm_xgl=$(grep "xorg-x11-server-Xgl-[0-9][^\"]*.$ARCH.rpm" xgl.html -o|tail -n 1) # rpm_xgl_set=$(grep "$NOM_SETTINGS-[0-9][^\"]*.noarch.rpm" xgl.html -o|tail -n 1) tmp=$(grep "xorg-x11-server-Xgl-[0-9][^\"]*.$ARCH.rpm" xgl.html -o|sed "s/\./-/g"|sed "s/-\([0-9]\)-/-0\1-/g"|sort -r|head -n 1) nTmp=$(grep "xorg-x11-server-Xgl-[0-9][^\"]*.$ARCH.rpm" xgl.html -o|sed "s/\./-/g"|sed "s/-\([0-9]\)-/-0\1-/g"|grep $tmp -n -m 1|cut -d':' -f1) rpm_xgl=$(grep "xorg-x11-server-Xgl-[0-9][^\"]*.$ARCH.rpm" xgl.html -o|head -n $nTmp|tail -n 1) tmp=$(grep "$NOM_SETTINGS-[0-9][^\"]*.noarch.rpm" xgl.html -o|sed "s/\./-/g"|sed "s/-\([0-9]\)-/-0\1-/g"|sort -r|head -n 1) nTmp=$(grep "$NOM_SETTINGS-[0-9][^\"]*.noarch.rpm" xgl.html -o|sed "s/\./-/g"|sed "s/-\([0-9]\)-/-0\1-/g"|grep $tmp -n -m 1|cut -d':' -f1) rpm_xgl_set=$(grep "$NOM_SETTINGS-[0-9][^\"]*.noarch.rpm" xgl.html -o|head -n $nTmp|tail -n 1) if [ -n "$rpm_xgl" ] && [ -n "$rpm_xgl_set" ]; then # vérifier si il y a une màj disponible if [ $DJ_INST -eq 0 ]; then #derniere_version=$(echo -e \ # "$(echo "$rpm_xgl"|sed "s/\.[^\.]*\.*rpm$//")\n$version_xgl"| \ # sort -r|head -n 1) derniere_version=$(echo "$rpm_xgl"|sed "s/\.[^\.]*\.*rpm$//") if [ $derniere_version = $version_xgl ]; then etat=-2 msg "The installed version of XGL ($derniere_version) is already the last one." else texte[$n]="Update of XGL" msg "An update of XGL is available \ \n\told version : $version_xgl \ \n\tnew version : $derniere_version\n" fi fi else erreur="rpm of XGL not found at $SITE_XGL !" [ $DJ_INST -eq 0 ] && etat=1 || etat=-1 fi else erreur="An error occured with the site of the XGL's rpm ($SITE_XGL).\nXGL is perhaps not available for your Fedora version or your architecture..." [ $DJ_INST -eq 0 ] && etat=1 || etat=-1 fi rm xgl.html #téléchargement if [ $etat -eq 0 ]; then wget -c $SITE_XGL$rpm_xgl wget -c $SITE_XGL$rpm_xgl_set if [ ! -f $rpm_xgl ] || [ ! -f $rpm_xgl_set ]; then erreur="Error while downloading '$rpm_xgl' or '$rpm_xgl_set'." [ $DJ_INST -eq 0 ] && etat=1 || etat=-1 else INSTALL_XGL=1 fi fi #Installation de XGL menu if [ ! "$INSTALL_XGL" = "1" ]; then INSTALL_XGL=0 etat=-2 else if ! rpm -q glitz-glx>/dev/null; then yum -y install glitz-glx if [ $? -ne 0 ]; then erreur="Error while installing the dependencies (glitz-glx) of XGL." stop fi fi rpm -Uhv $rpm_xgl $rpm_xgl_set --test >/dev/null 2>&1 if [ $? -eq 0 ]; then rpm -Uhv $rpm_xgl $rpm_xgl_set --noscripts installOK=$? else msg "Dependencies are needed to install XGL:" [ $FED_VERSION -ge 7 ] && YUM_OPT="--nogpgcheck" || YUM_OPT="" yum install $rpm_xgl $rpm_xgl_set $YUM_OPT rpm -q xorg-x11-server-Xgl>/dev/null installOK=$? fi if [ $installOK -ne 0 ] ; then etat=-1 erreur="Error at the installation of the RPM of XGL." else rm -f $rpm_xgl $rpm_xgl_set rpm -e --nodeps $NOM_SETTINGS fi fi #Configuration de XGL menu wget http://nicofo.tuxfamily.org/scripts/xgl/xgl-settings.tar.gz -O xgl-settings.tar.gz if [ ! -s xgl-settings.tar.gz ]; then erreur="Error while downloading 'http://nicofo.tuxfamily.org/scripts/xgl/xgl-settings.tar.gz'." etat=-1 else tar -xzf xgl-settings.tar.gz #traduction en anglais de 'chooseCompositeWM' FR=( "(avec" "(sans" "(Aucun gestionnaire de fenêtres composite)" "Gestionnaire de fenêtres avec XGL" "Quel gestionnaire de fenêtres voulez-vous avec XGL ?" "--column=\"Gestionnaire de fenêtres\"" "\"\(.*\) n'est pas installé.* avec \([^ ]\+\) :" "installXGL" "Voulez-vous appliquer la.*session." "XGL n'est.*session XGL." ) EN=( "(with" "(without" "(No composite window manager)" "Composite window manager with XGL" "Which composite window manager do you want with XGL ?" "--column=\"Window manager\"" "\"\1 is not installed ! \\\nYou can easily install it using \2:" "installXGL_EN" "Do you want to apply the modification now ?\\\n\\\nOtherwise, the modification will take place with the next starting of your session." "XGL is not running.\\\n\\\nThe modification will take place with the next starting of your XGL session." ) i=0 for fr in "${FR[@]}"; do # echo "$fr -> ${EN[$i]}" sed -i "s/$fr/${EN[$i]}/g" chooseCompositeWM i=$(($i+1)) done ./configureXgl if [ $? -ne 0 ]; then etat=-1; fi rm -f xgl-settings.tar.gz $(tar -tf xgl-settings.tar.gz) fi #Installation de Beryl et Compiz menu if [ $DJ_INST -ne 0 -a $INSTALL_XGL -eq 1 ] || [ ! -f /usr/bin/beryl -a ! -f /usr/bin/compiz ] ; then #1ère install XGL ou compiz et beryl non installés installCompizBeryl #renvoie 1 si n'a rien installé [ $? -eq 1 ] && etat=-2 || etat=0 else etat=-2 fi #Fin menu echo -e "You can now install \033[1mCompiz\033[0m, \033[1mCompiz-fusion\033[0m or \033[1mBeryl\033[0m with" echo -e "\t\033[0;34m$(basename $0) -cb\033[0m\n\n" echo -e "Installation finished. You can now launch a new GNOME, KDE or XFCE session and\nchoose \033[1mXGL\033[0m." echo -e "At any time you can choose to use \033[1mCompiz\033[0m or \033[1mBeryl\033[0m through the Gnome/KDE menu -> Preferences/Settings -> \"XGL Window Manager\"."