README.md | 6 ++++++ nnn.1 | 6 ++++++ nnn.c | 6 +++++- diff --git a/README.md b/README.md index acc500ef858cabbf442fdbccc4ea6b1567465623..5540e6965ca47f90bcacecb70165a46a5fb3c090 100644 --- a/README.md +++ b/README.md @@ -353,6 +353,12 @@ #### set idle timeout The terminal screensaver is disabled by default. To set the wait time in seconds, use environment variable `NNN_IDLE_TIMEOUT`. +#### open file in new process and make the nnn not block + +The desktop file opener should take care of opening files in new processes without causing `nnn` to block. +If `nnn` does block/freeze when a file is open, then set the environment variable `NNN_NOWAIT` to any +non-zero value. + ### Why fork? I chose to fork because: diff --git a/nnn.1 b/nnn.1 index 9ad5c824245021b4f4a8c71ccab25c2cf92bb82e..13d7c35168199095174457ac2edda733f1ea4871 100644 --- a/nnn.1 +++ b/nnn.1 @@ -207,6 +207,12 @@ echo -n $1 | xsel --clipboard --input ------------------------------------- .Ed +.Pp +\fBNNN_NOWAIT:\fR make nnn not block while a file is open. Only necessary if +nnn is blocking while a file is open. +.Bd -literal + export NNN_NOWAIT=1 +.Ed .Sh KNOWN ISSUES If you are using urxvt you might have to set backspacekey to DEC. .Sh AUTHORS diff --git a/nnn.c b/nnn.c index 3b0ac02a5448ae8f46518880f99f34ae089a9275..1b1ba40898587e1540417fb2e439f1947b5045e3 100644 --- a/nnn.c +++ b/nnn.c @@ -222,6 +222,7 @@ static char *player; static char *copier; static char *editor; static char *desktop_manager; +static char nowait; static blkcnt_t ent_blocks; static blkcnt_t dir_blocks; static ulong num_files; @@ -2211,7 +2212,7 @@ } } /* Invoke desktop opener as last resort */ - spawn(utils[2], newpath, NULL, NULL, F_NOTRACE); + spawn(utils[2], newpath, NULL, NULL, nowait); continue; } default: @@ -2862,6 +2863,9 @@ idletimeout = abs(atoi(copier)); /* Get the default copier, if set */ copier = getenv("NNN_COPIER"); + + /* Get nowait flag */ + nowait = F_NOTRACE | (getenv("NNN_NOWAIT") ? F_NOWAIT : 0); signal(SIGINT, SIG_IGN);