Luke Mitchell - 2015-05-18

Hi

Thanks for the great example, it's really interesting.

However, if you're like me and have installed yad using debian package management then the above script won't work. As yad isn't located in /usr/desktop/bin/ (not sure if this is the make install location), its installed in /usr/bin/,

You could of course do a find replace through the script to update the location, or you can use the slight variation attached, that will automatically check the location of yad and update the script on the fly.

The modification, checks the original location in the example, as well as /usr/bin. If they both fail it which attempt to find yad in the environment path. If that also fails, it will exit with an error asking the user to update the variable "YadLocal" near the top of the script with the correct yad location. Finally it confirms YadLocal is an executable file before attempting to use it.

# Set yad binary location   - LGM May 2015
# Add the path to yad in YadLocal below only if the script can't find yad.
YadLocal="" 
# Use YadLocal if defined and file is executable
if [ ! -z ${YadLocal} ] && [ -x ${YadLocal} ]; then
    YAD=${YadLocal}
# Default location given in original notebook script (yad make install location?)
elif [ -x /usr/desktop/bin/yad ]; then
    YAD="/usr/desktop/bin/yad"
# Default Debian, Mint, Ubuntu location
elif [ -x /usr/bin/yad ]; then
    YAD="/usr/bin/yad"
else
    # Final desperate guess to see if yad is in the $PATH
    YAD=$( which yad )
    # If yad still not found or still blank error and exit
    if [ -z ${YAD} ] || [ ! -x ${YAD} ]; then 
        echo -e "\nERROR: UNABLE TO LOCATE YAD PROGRAM EXITING...\n \
                Please add the full path to yad in 'YadLocal' at the top of ${0}\n" >2; exit
    fi
fi

Hope this is helpful and saves some frustration.

Cheers
Luke

PS There seems to be some issue with the text mark-up, if I attempted to use either "#! /bin/sh" or ":::sh" to highlight the code block it turned it in to some sort of MS Word type doc, stripping '#' and turning those lines into 16+pt bold headings. Only the 6 tildes seems to work as referenced in the formatting help.

 

Last edit: Luke Mitchell 2015-05-19