mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 13:51:31 +00:00
Support NOICE_FALLBAK_OPENER.
This commit is contained in:
parent
26f7af74fd
commit
95ca9c3a95
15
noice.c
15
noice.c
|
@ -86,6 +86,7 @@ struct entry *dents;
|
||||||
int ndents, cur;
|
int ndents, cur;
|
||||||
int idle;
|
int idle;
|
||||||
char *opener = NULL;
|
char *opener = NULL;
|
||||||
|
char *fallback_opener = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Layout:
|
* Layout:
|
||||||
|
@ -658,7 +659,8 @@ nochange:
|
||||||
char cmd[MAX_LEN];
|
char cmd[MAX_LEN];
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
snprintf(cmd, MAX_LEN, "%s \"%s\" > /dev/null 2>&1", opener, newpath);
|
snprintf(cmd, MAX_LEN, "%s \"%s\" > /dev/null 2>&1",
|
||||||
|
opener, newpath);
|
||||||
status = system(cmd);
|
status = system(cmd);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -686,10 +688,14 @@ nochange:
|
||||||
|
|
||||||
if (strstr(cmd, "ASCII text") != NULL)
|
if (strstr(cmd, "ASCII text") != NULL)
|
||||||
bin = execvim;
|
bin = execvim;
|
||||||
else {
|
else if (fallback_opener) {
|
||||||
snprintf(cmd, MAX_LEN, "xdg-open \"%s\" > /dev/null 2>&1", newpath);
|
snprintf(cmd, MAX_LEN, "%s \"%s\" > /dev/null 2>&1",
|
||||||
|
fallback_opener, newpath);
|
||||||
status = system(cmd);
|
status = system(cmd);
|
||||||
continue;
|
continue;
|
||||||
|
} else {
|
||||||
|
printmsg("No association");
|
||||||
|
goto nochange;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exitcurses();
|
exitcurses();
|
||||||
|
@ -849,6 +855,9 @@ main(int argc, char *argv[])
|
||||||
/* Get the default desktop mime opener, if set */
|
/* Get the default desktop mime opener, if set */
|
||||||
opener = getenv("NOICE_OPENER");
|
opener = getenv("NOICE_OPENER");
|
||||||
|
|
||||||
|
/* Get the fallback desktop mime opener, if set */
|
||||||
|
fallback_opener = getenv("NOICE_FALLBACK_OPENER");
|
||||||
|
|
||||||
signal(SIGINT, SIG_IGN);
|
signal(SIGINT, SIG_IGN);
|
||||||
|
|
||||||
/* Test initial path */
|
/* Test initial path */
|
||||||
|
|
Loading…
Reference in a new issue