projects
/
XGrabControl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ee038c1
)
Make wrapper script more intelligent and beautiful
author
norly
<ny-git@enpas.org>
Wed, 20 Feb 2013 23:31:06 +0000
(23:31 +0000)
committer
norly
<ny-git@enpas.org>
Wed, 20 Feb 2013 23:31:06 +0000
(23:31 +0000)
XGrabControl
patch
|
blob
|
history
diff --git
a/XGrabControl
b/XGrabControl
index 1154a704bcd74b0d8ecf8d7ee86457db0bb63e78..57f2c1d25b9823429d08853f3dc27fe3e11d1c02 100755
(executable)
--- a/
XGrabControl
+++ b/
XGrabControl
@@
-9,14
+9,34
@@
# or use it as a program running helper:
# XGrabControl program arg1 arg2 ...
# 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.
# 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
then
- echo "
XGrabControl: A
lready in LD_PRELOAD."
+ echo "
$MYNAME: $SONAME is a
lready in LD_PRELOAD."
else
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.
fi
# If any arguments were given, pass them on to the shell.
@@
-24,3
+44,4
@@
if [ $# -gt 0 ]
then
exec "$@"
fi
then
exec "$@"
fi
+