Skip to content

Commit

Permalink
Wrapper: get rid of bashism, provide better error in some cases
Browse files Browse the repository at this point in the history
In case the symlink to gtk3-nocsd is the only command present in PATH
with the correct name, instead of just falling back to /bin/false,
pretend to execute /.gtk3-nocsd./$APPNAME - so that the user will get
an error message that might help a little in figuring out what's wrong.

Also, use /bin/sh and not /bin/bash in shebang.
  • Loading branch information
chris-se committed Oct 15, 2015
1 parent 97bc3b3 commit 3bfa40f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gtk3-nocsd.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
#
# gtk3-nocsd - Wrapper to apply gtk3-nocsd to application
#
Expand Down Expand Up @@ -72,11 +72,16 @@ fi

# Find the real program (the first one that's not symlinked to get3-nocsd)
APPNAME="$(basename "$0")"
for APPPATH in $(type -Pa "$APPNAME") /bin/false; do
for APPPATH in $(which -a "$APPNAME") /bin/false; do
APPPATH_LINK="$(readlink -fe "$APPPATH")"
[ x"${APPPATH_LINK##*/}"x = x"gtk3-nocsd"x ] || break
done

# Provide error message at all
if [ x"$APPNAME"x != x"false"x ] && [ x"${APPPATH}"x = x"/bin/false"x ] ; then
APPPATH=/.gtk3-nocsd./"$APPNAME"
fi

# Run the program with CSD disabled
export LD_PRELOAD="${GTK3_NOCSD}${LD_PRELOAD:+:$LD_PRELOAD}"
export GTK_CSD=0
Expand Down

0 comments on commit 3bfa40f

Please sign in to comment.