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.
Advertisement
Start script for linux urban terror
#3
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:
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.
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.
#5
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.
Advertisement
#6
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
Posted 26 April 2011 - 12:22 PM
I know this is an Old Thread but maybe someone has interrest:
It is just one grep neccessary:
Rinsmaster, 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
#9
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
HTH
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
1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users
Advertisement