Change LICENSE to CC0
[XGrabControl.git] / noxg
1 #!/bin/sh
2 #
3 # XGrabControl, part of XGrabControl.
4 # (c) 2011, en passant development.
5 #
6 # This is a simple wrapper script for XGrabControl.
7 # Either source it or use it:
8 #   source XGrabControl
9 # or use it as a program running helper:
10 #   XGrabControl program arg1 arg2 ...
11
12 MYNAME="XGrabControl"
13 SONAME=libXGrabControl.so
14
15
16 # Try to find $SONAME
17 for n in $PWD "${0%/*}" /usr/lib /usr/local/lib
18 do
19   if [ -e "$n/$SONAME" ]
20   then
21     SOPATH="$n/$SONAME"
22     break
23   fi
24 done
25
26 if [ -z "$SOPATH" ]
27 then
28   echo "$MYNAME: Could not find $SONAME. Aborting."
29   exit 1
30 fi
31
32
33 # Insert ourselves into LD_PRELOAD if we are not there yet.
34 if echo $LD_PRELOAD | grep -q "$SONAME" # $SONAME is treated as a regexp
35 then
36   echo "$MYNAME: $SONAME is already in LD_PRELOAD."
37 else
38   echo "$MYNAME: Adding $SOPATH to LD_PRELOAD."
39   export LD_PRELOAD="$SOPATH $LD_PRELOAD"
40 fi
41
42 # If any arguments were given, pass them on to the shell.
43 if [ $# -gt 0 ]
44 then
45   exec "$@"
46 fi