summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornorly <ny-git@enpas.org>2013-02-20 23:31:06 +0000
committernorly <ny-git@enpas.org>2013-02-20 23:31:06 +0000
commit560737238e48791914d423c98323fffd94dd5b28 (patch)
treebb7fc4e85b1e7b3aa518e339aff2952c0d5379f5
parentee038c113a77482d8800a1e90d56dd5f2413d6be (diff)
Make wrapper script more intelligent and beautiful
-rwxr-xr-xXGrabControl29
1 files changed, 25 insertions, 4 deletions
diff --git a/XGrabControl b/XGrabControl
index 1154a70..57f2c1d 100755
--- a/XGrabControl
+++ b/XGrabControl
@@ -9,14 +9,34 @@
# or use it as a program running helper:
# XGrabControl program arg1 arg2 ...
+MYNAME="${0#*/}"
+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 "libXGrabControl\.so"
+if echo $LD_PRELOAD | grep -q "$SONAME" # $SONAME is treated as a regexp
then
- echo "XGrabControl: Already in LD_PRELOAD."
+ echo "$MYNAME: $SONAME is already in LD_PRELOAD."
else
- echo "XGrabControl: Adding to LD_PRELOAD."
- export LD_PRELOAD="libXGrabControl.so $LD_PRELOAD"
+ 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.
@@ -24,3 +44,4 @@ if [ $# -gt 0 ]
then
exec "$@"
fi
+