aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2016-08-21 15:49:54 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2016-08-21 15:49:54 +0530
commit95ca9c3a951f152ea102536df08288fece377c25 (patch)
tree11e97b16953775a0b47defd210dfd0a18b52093b
parent26f7af74fd4f505f4becdc545ff4029d3fbdcbab (diff)
downloadnnn-95ca9c3a951f152ea102536df08288fece377c25.tar.gz
Support NOICE_FALLBAK_OPENER.
-rw-r--r--noice.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/noice.c b/noice.c
index ee58772..7ba3796 100644
--- a/noice.c
+++ b/noice.c
@@ -86,6 +86,7 @@ struct entry *dents;
int ndents, cur;
int idle;
char *opener = NULL;
+char *fallback_opener = NULL;
/*
* Layout:
@@ -658,7 +659,8 @@ nochange:
char cmd[MAX_LEN];
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);
continue;
}
@@ -686,10 +688,14 @@ nochange:
if (strstr(cmd, "ASCII text") != NULL)
bin = execvim;
- else {
- snprintf(cmd, MAX_LEN, "xdg-open \"%s\" > /dev/null 2>&1", newpath);
+ else if (fallback_opener) {
+ snprintf(cmd, MAX_LEN, "%s \"%s\" > /dev/null 2>&1",
+ fallback_opener, newpath);
status = system(cmd);
continue;
+ } else {
+ printmsg("No association");
+ goto nochange;
}
}
exitcurses();
@@ -849,6 +855,9 @@ main(int argc, char *argv[])
/* Get the default desktop mime opener, if set */
opener = getenv("NOICE_OPENER");
+ /* Get the fallback desktop mime opener, if set */
+ fallback_opener = getenv("NOICE_FALLBACK_OPENER");
+
signal(SIGINT, SIG_IGN);
/* Test initial path */