From: John Stone (johns_at_ks.uiuc.edu)
Date: Sun Apr 26 2020 - 14:33:34 CDT

I don't want it in the hard-coded platform-dependent startup, but
I'm willing for it to end up in either early Tcl startup or later
C++ startup in the OS-independent part of the code. I'll look at
it this week.

Best,
  John

On Sun, Apr 26, 2020 at 11:49:57AM +0200, FX wrote:
> > Would you accept a patch to add code in macosxvmdstart.C that auto-detects its presence in PATH? Currently, VMD expects VMDBABELBIN to be set, even if I have an obabel binary in my PATH. In my case, I have open babel installed and VMD won???t use it, which is not an ideal experience.
>
> Here is code that works for me:
>
>
> char *find_babel(void) {
> char *token, *s, *path;
> char tmp[1024];
>
> path = s = strdup(getenv("PATH"));
> while ((token = strsep(&s, ":"))) {
> strcpy(tmp, token);
> strcat(tmp, "/obabel");
> if (access(tmp, X_OK) == 0) {
> printf("Info) Found Open Babel binary at: %s\n", tmp);
> free(path);
> return strdup(tmp);
> }
> }
>
> free(path);
> return NULL;
> }
>
>
> and then at the end of macosxvmdstart():
>
> if (!getenv("VMDBABELBIN")) {
> char *babel = find_babel();
> setenv("VMDBABELBIN", babel, 1);
> free(babel);
> }
>
>
> That way it does not override an explicit environment variable, but will auto-detect babel if it???s installed in the PATH.
>
> FX

-- 
NIH Center for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
http://www.ks.uiuc.edu/~johns/           Phone: 217-244-3349
http://www.ks.uiuc.edu/Research/vmd/