summaryrefslogtreecommitdiff
path: root/noxg
blob: ddc64b15e0b5e5617fcede193256c5ad17d0d2ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
#
# XGrabControl, part of XGrabControl.
# (c) 2011, en passant development.
#
# This is a simple wrapper script for XGrabControl.
# Either source it or use it:
#   source XGrabControl
# or use it as a program running helper:
#   XGrabControl program arg1 arg2 ...

MYNAME="XGrabControl"
SONAME=libXGrabControl.so


# Try to find $SONAME
for n in $PWD "${0%/*}" /usr/lib /usr/local/lib
do
  if [ -e "$n/$SONAME" ]
  then
    SOPATH="$n/$SONAME"
    break
  fi
done

if [ -z "$SOPATH" ]
then
  echo "$MYNAME: Could not find $SONAME. Aborting."
  exit 1
fi


# Insert ourselves into LD_PRELOAD if we are not there yet.
if echo $LD_PRELOAD | grep -q "$SONAME" # $SONAME is treated as a regexp
then
  echo "$MYNAME: $SONAME is already in LD_PRELOAD."
else
  echo "$MYNAME: Adding $SOPATH to LD_PRELOAD."
  export LD_PRELOAD="$SOPATH $LD_PRELOAD"
fi

# If any arguments were given, pass them on to the shell.
if [ $# -gt 0 ]
then
  exec "$@"
fi