Urban Terror Forums: Start script for linux urban terror - Urban Terror Forums

Jump to content

 Login | Register 
Advertisement
  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • This topic is locked

Start script for linux urban terror Rate Topic: -----

#1 User is offline   kharisym (old) Icon

  • Joined: 29-July 09
  • Posts: 5

Posted 29 July 2009 - 05:33 PM

Anyone have a start script that checks the PID for an existing UT game and starts only if one isn't already running? I use both windows and linux so sometimes I accidentally double-click instead of single-click.

#2 User is offline   Rinsmaster Icon

  • Account: rinsmaster
  • Main tag: O.O|
  • Country:
  • Joined: 28-February 10
  • Posts: 170

Posted 29 July 2009 - 09:58 PM

Something like this (not tested)

#!/bin/bash

if [ `ps ax | grep -v grep | grep "ioUrbanTerror.i386" | wc -l` -eq 1 ]
then
        /path/to/ioUrbanTerror.i386
fi



#3 User is offline   kharisym (old) Icon

  • Joined: 29-July 09
  • Posts: 5

Posted 29 July 2009 - 11:28 PM

Almost! I'm knew it'd involve grep and I'm horrible with grep, so thank you very much for that.

Here's the code that works on my system:

#!/bin/bash

if [ `ps ax | grep -v grep | grep "ioUrbanTerror.i" | wc -l` -eq 0 ]
then
        ~/UrbanTerror/ioUrbanTerror.i386
fi


Thank you very much for doing the lion's share of the work. I did notice that when I double click the actual executable I get a regular window and lose mouse and keyboard clickiness, so this solves that issue.

#4 User is offline   Spectre Icon

  • Account: spectre
  • Joined: 03-March 10
  • Posts: 703

Posted 31 July 2009 - 03:37 AM

what about a script that does this, but also disables compiz for you? Would there be a way to make it like continuasly check to see if the game is running, and then once you close the game for it to reactivate compiz?

#5 User is offline   mauve (old) Icon

  • Joined: 27-July 09
  • Posts: 2

Posted 31 July 2009 - 01:37 PM

Quote

what about a script that does this, but also disables compiz for you? Would there be a way to make it like continuasly check to see if the game is running, and then once you close the game for it to reactivate compiz?


Not need to make a continous check ; a script waits after launching an external process and collects the exit code upon termination of the spawned process. One just needs to reactivate compiz after UTr exits in the script.

bullet_loaderAdvertisement

#6 User is offline   Rinsmaster Icon

  • Account: rinsmaster
  • Main tag: O.O|
  • Country:
  • Joined: 28-February 10
  • Posts: 170

Posted 31 July 2009 - 06:43 PM

Quote

what about a script that does this, but also disables compiz for you? Would there be a way to make it like continuasly check to see if the game is running, and then once you close the game for it to reactivate compiz?

That would be something like (If you're on Gnome):

#!/bin/bash

if [ `ps ax | grep -v grep | grep "ioUrbanTerror.i" | wc -l` -eq 0 ]
then
        metacity --replace
        ~/UrbanTerror/ioUrbanTerror.i386
        compiz --replace
fi



#7 User is offline   ItsMe Icon

  • Account: itsme
  • Main tag: bc`
  • Joined: 28-February 10
  • Posts: 76

Posted 26 April 2011 - 12:22 PM

I know this is an Old Thread but maybe someone has interrest:

View PostRinsmaster, on 31 July 2009 - 06:43 PM, said:


#!/bin/bash

if [ `ps ax | grep -v grep | grep "ioUrbanTerror.i" | wc -l` -eq 0 ]
then
        metacity --replace
        ~/UrbanTerror/ioUrbanTerror.i386
        compiz --replace
fi



It is just one grep neccessary:


#!/bin/bash

if [ `ps ax | grep [io]U | wc -l` -eq 0 ]
then
        metacity --replace
        ~/UrbanTerror/ioUrbanTerror.i386
        compiz --replace
fi




#8 User is offline   BasementCat Icon

  • Account: basementcat
  • Country:
  • Joined: 04-March 10
  • Posts: 67

Posted 27 April 2011 - 07:10 AM

An alternative using 'pidof' instead of ps + grep:


#!/bin/bash

if pidof ioUrbanTerror.i386 &> /dev/null; then
    # Urban Terror is already running.
else
    metacity --replace
    ~/UrbanTerror/ioUrbanTerror.i386
    compiz --replace
fi



#9 User is offline   ItsMe Icon

  • Account: itsme
  • Main tag: bc`
  • Joined: 28-February 10
  • Posts: 76

Posted 30 April 2011 - 04:08 PM

An alternative using 'pidof' instead of ps + grep:

got me :)

atm i use the following script to start UrT:
(I've added a few Comments to the Script so it is better readable)

Download it at:
urbanterror.sh




#!/bin/bash
#
# Provides      : Startup of the UrT Client
# Description   : Checking for a running UrT Instance 
#                 give a Notification and
#                 start the UrT Client when needed
#                 
# Limitations   : The Scrpit is tested/ developed for running
#                 in a GNOME Environment, I did -> NO <- Tests
#                 with KDE or other Desktop Environments.
#
# Options       : -i give an IP ADDRESS to connect to
#                 -c give a config to load
#                 -h short Help/ Description
#
# Modified      : 04|30|2011
# Author        : ItsMe
# Reply to      : itsme@bubbleclub.de		
#
#########################################################
# 
# OK - Lets Work
#

# Variables and Settings
# and
# used Utils and programs
#
#
msg="" 
config=""
ip=""
xset=/usr/bin/xset
taskset=/bin/taskset
tsopt="-c 1"
compiz=/usr/bin/compiz
metacity=/usr/bin/metacity

# get Commandline Options if some given and fill the variables with data ($ip and $config)
#
# -c for configfile to load
# -i for Server IP to connect to
# -h for help
#
# all Options are NOT mandatory
usage=`echo -e "Usage: \033[1m-i\033[0m IP Address; \033[1m-c\033[m Config file to use; \033[1m-h\033[0m Help - Example: \033[1murbanterror.sh -i 188.40.128.151:57960\033[0m"`
while getopts "i:c:h" opt; do
  case $opt in
    i)  if [ -n $OPTARG ]; then
            ip="+connect "$OPTARG
        fi
        ;;
    c)  if [ -n $OPTARG ]; then
            config="+exec "$OPTARG
        fi
        ;;
    h)  echo $usage
        exit 0
        ;;
        
    \?) echo "Invalid option: -$OPTARG" >&2
        exit 1
        ;;
  esac
done

# Get the Machinetype so we can use the right binary - i386 or x86_64
arch=`uname -m`


# Catch the PIDs of a running Instances of:
#
# UrT
# Metacity
# Compiz
#
# when no Instance is running it will be empty
# In the case you run other Windowmanagers (eg. Blackbox or Icewm) adjust that to your needs
pidU=`pidof ioUrbanTerror.$arch`
pidC=`pidof compiz`
pidM=`pidof metacity`

# path to the binary(s)
game=~/urbanterror/ioUrbanTerror.$arch

# Set Mouse Accelleration and threshold to 0
# You can get the actual data with xset q
# But I prefer no Acceleration and no threshold so I do not test
# the actual data to restore them and just set it to zero
xset m 0 0

# Inform you if its running or not
# Notice:
# libnotify has to be installed to get nice looking Desktop Infos
# else you get a notice in the console only.
function notify () {
    if [[ -e /usr/bin/notify-send ]]; then
            notify-send -i urt "$msg"
    else
            echo $msg
    fi
}

# Check if compiz is running, if yes change the Windowmanager to Metacity
# and start Urban Terror
# Replace the Windowmanager back to Compiz when we exit the game
function run (){
    if [ -z "$pidC" ]; then
        $taskset $tsopt $game $config $ip
    else
        $metacity --replace
        $taskset $tsopt $game $config $ip
        $compiz --replace
    fi
}

# Is UrT running?
if [ -z "$pidU" ]; then
    msg="Starting Urban Terror... "
    notify
    run
else
    # Quick and Dirty Workaround to get a linebreak into the Notification Area
    msg=`echo -e "Urban Terror is still running\nPID: "$pidU`
    notify
fi


# EOF





HTH

#10 User is offline   Evilslut Icon

  • Account: evilslut
  • Joined: 01-March 10
  • Posts: 98

Posted 17 June 2011 - 10:35 AM

Looks nice ItsMe, i should try this one, specially on a sunny day...

Though i generally play when the sun is under, it does happen i play during the day, and often i can't see the enemy if im not blue/red (depending on map).

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users

Advertisement


Copyright © 1999-2024 Frozensand Games Limited  |  All rights reserved  |  Urban Terror™ and FrozenSand™ are trademarks of Frozensand Games Limited

Frozensand Games is a Limited company registered in England and Wales. Company Reg No: 10343942