diff options
| author | 2019-05-15 09:14:28 +0530 | |
|---|---|---|
| committer | 2019-05-22 08:44:19 +0530 | |
| commit | 95eaa636efbf7a9a63d9489b11163a8cc8c28a97 (patch) | |
| tree | 91ec88beb6e40824b1dfdbe2676801887ac2c918 | |
| parent | 3ca86eafbe899a448799832f8ad65d15a01f6e57 (diff) | |
| download | nnn-95eaa636efbf7a9a63d9489b11163a8cc8c28a97.tar.gz | |
Fix #261
| -rw-r--r-- | src/nnn.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -4360,6 +4360,10 @@ int main(int argc, char *argv[]) if (!setup_config()) return 1; + /* Get custom opener, if set */ + opener = xgetenv(env_cfg[NNN_OPENER], utils[OPENER]); + DPRINTF_S(opener); + /* Parse bookmarks string */ if (!parsebmstr()) { fprintf(stderr, "%s\n", env_cfg[NNN_BMS]); @@ -4387,6 +4391,23 @@ int main(int argc, char *argv[]) xerror(); return 1; } + + /* + * If nnn is set as the file manager, applications may try to open + * files by invoking nnn. In that case pass the file path to the + * desktop opener and exit. + */ + struct stat sb; + + if (stat(initpath, &sb) == -1) { + xerror(); + return 1; + } + + if (S_ISREG(sb.st_mode)) { + execlp(opener, opener, arg, NULL); + return 0; + } } /* Edit text in EDITOR, if opted */ |