Compiz + 3D Application (Quake3) <= Compatible with XQF

Moderators: digital, horus

Compiz + 3D Application (Quake3) <= Compatible with XQF

Postby analyzer on 01 May 2008, 21:12

Code: Select all
#!/bin/bash
# 3D launcher by analyzer (requesthelp@free.fr)
app=quake3

# Normal color
NORMAL='\033[0;39m'
# RED: Error message
RED='\033[1;31m'
# YELLOW: Warning message
YELLOW='\033[1;33m'
# GREEN: Success message
GREEN='\033[1;32m'

RES_COL=70
MOVE_TO_COL="\\033[${RES_COL}G"

function q3launcher() {
   # Killing Windows Manager
   [[ $(pgrep compiz) > 0 ]] && killall -9 compiz && echo -e "Killing compiz $MOVE_TO_COL[ ${GREEN}OK${NORMAL} ]" && PHASECOMPIZ=1

   # Killing Windows Decorator
   [[ $(pgrep emerald) > 0 ]] && killall -9 emerald && echo -e "Killing emerald $MOVE_TO_COL[ ${GREEN}OK${NORMAL} ]" && PHASEEMERALD=1
   [[ $(pgrep gtk-window-decorator) > 0 ]] && killall -9 gtk-window-decorator && echo -e "Killing gtk-window-decorator $MOVE_TO_COL[ ${GREEN}OK${NORMAL} ]" && PHASEGTK=1

   # Replacing Windows Manager
   if [ -n "$KDE_FULL_SESSION" ]; then
      if [[ ! $(pgrep kwin) > 0 ]]; then
         echo -n "Starting kwin"
         kwin --replace &

         if [ $? -eq 0 ] ; then
            PHASEKWIN=1
            echo -e "$MOVE_TO_COL[ ${GREEN}OK${NORMAL} ]"
         else
            echo -e "$MOVE_TO_COL[ ${RED}KO${NORMAL} ]"
         fi
      fi
   else
      if [[ ! $(pgrep metacity) > 0 ]]; then
         echo -n "Starting metacity"
         metacity --replace &

         if [[ $? -eq 0 ]]; then
            PHASEKMETA=1
            echo -e "$MOVE_TO_COL[ ${GREEN}OK${NORMAL} ]"
         else
            echo -e "$MOVE_TO_COL[ ${RED}KO${NORMAL} ]"
         fi
      fi
   fi

   if [ $# -eq 0 ]; then
      if [[ -z $password ]]; then
         echo "Connecting to '$arguments' without password"
         $app +connect $arguments 2>/dev/null 1>/dev/null
      else
         echo "Connecting to '$arguments' with pass='$password'"
         $app +connect $arguments +password $password 2>/dev/null 1>/dev/null
      fi
   else
      echo "Automatic connection string detected '$*'"
      $app $*
   fi

   # Killing Windows Manager
   [[ -n $PHASEKWIN ]] && [[ $(pgrep kwin) > 0 ]] && killall -9 kwin && echo -e "Killing kwin $MOVE_TO_COL[ ${GREEN}OK${NORMAL} ]"
   [[ -n $PHASEMETA ]] && [[ $(pgrep metacity) > 0 ]] && killall -9 metacity && echo -e "Killing metacity $MOVE_TO_COL[ ${GREEN}OK${NORMAL} ]"
   sleep 1

   # Killing Windows Decorator
   [[ -n $PHASEGTK ]] && [[ ! $(pgrep gtk-window-decorator) > 0 ]] && echo -e "Starting gtk-window-decorator $MOVE_TO_COL[ ${GREEN}OK${NORMAL} ]" && gtk-window-decorator --replace 2>/dev/null 1>/dev/null &
   [[ -n $PHASEEMERALD ]] && [[ ! $(pgrep emerald) > 0 ]] && echo -e "Starting emerald $MOVE_TO_COL[ ${GREEN}OK${NORMAL} ]" && emerald --replace 2>/dev/null 1>/dev/null &
   sleep 1

   # Replacing Windows Manager
   [[ -n $PHASECOMPIZ ]] && [[ ! $(pgrep compiz) > 0 ]] && echo -e "Starting compiz $MOVE_TO_COL[ ${GREEN}OK${NORMAL} ]" && nohup compiz --replace --sm-disable --ignore-desktop-hints ccp --indirect-rendering 2>/dev/null 1>/dev/null &
}

## REAL START OF BASH SCRIPT
if [ $# -eq 0 ]; then
   clipboard=`xsel -p | sed 's/^\s*//g' | sed 's/\s*$//g' | sed 's/\s+//g'`

   # First argument is the IP:PORT
   arguments=`echo $clipboard | cut -d " " -f1`

   # Last argument is the password
   last=`echo $clipboard | wc -w`
   password=`echo $clipboard | cut -d " " -f$last`
else
   if [ "${1:0:1}" = "+" ]; then
      q3launcher $*
      exit
   else
      # First argument is the IP:PORT
      arguments=$1
      # Last argument is the password
      [[ $# -gt 1 ]] && eval password="$"$#
   fi
fi

[[ -z $arguments ]] && echo "Usage: $0 ipaddress:port [password]" && exit 1

IP=`echo "$arguments" | grep -E "([0-9]{1,3}\.){3}([0-9]{1,3})"`
if [[ "$IP" ]]; then
   echo "$arguments" | cut -d: -f1 | awk -F. '{
      if ( (($1>=0) && ($1<=255)) && (($2>=0) && ($2<=255)) && (($3>=0) && ($3<=255)) && (($4>=0) && ($4<=255)) ) {
         print($0 " is a valid IP address.");
         exit 1;
      } else {
         print($0 " => IP address out of range!");
         exit 0;
      }
   }'

   [[ $? -eq 0 ]] && exit 2

   q3launcher
else
   echo "$arguments is not a valid IP address!"
   echo "Usage: $0 ipaddress:port [password]"
   exit 3
fi
analyzer
Administrateur
Administrateur
 
Posts: 27
Joined: 22 Mar 2005, 19:37

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron