Do not wait when spawning DE file manager

This commit is contained in:
Arun Prakash Jana 2017-04-22 19:49:00 +05:30
parent b19778fdff
commit 4790d17d04
No known key found for this signature in database
GPG key ID: A75979F35C080412
3 changed files with 19 additions and 14 deletions

View file

@ -139,8 +139,8 @@ nnn needs libreadline, libncursesw (on Linux or ncurses on OS X) and standard li
| `c` | Show change dir prompt | | `c` | Show change dir prompt |
| `d` | Toggle detail view | | `d` | Toggle detail view |
| `D` | Toggle current file details screen | | `D` | Toggle current file details screen |
| `m` | Show concise mediainfo in less | | `m` | Show concise mediainfo |
| `M` | Show full mediainfo in less | | `M` | Show full mediainfo |
| `.` | Toggle hide .dot files | | `.` | Toggle hide .dot files |
| `s` | Toggle sort by file size | | `s` | Toggle sort by file size |
| `S` | Toggle disk usage analyzer mode | | `S` | Toggle disk usage analyzer mode |

4
nnn.1
View file

@ -56,9 +56,9 @@ Toggle detail view
.It Ic D .It Ic D
Toggle current file details screen Toggle current file details screen
.It Ic m .It Ic m
Show concise mediainfo in less Show concise mediainfo
.It Ic M .It Ic M
Show full mediainfo in less Show full mediainfo
.It Ic \&. .It Ic \&.
Toggle hide .dot files Toggle hide .dot files
.It Ic s .It Ic s

19
nnn.c
View file

@ -280,8 +280,13 @@ xdirname(const char *path)
return buf; return buf;
} }
/*
* Spawns a child process. Behaviour can be controlled using flag:
* flag = 1: draw a marker to indicate nnn spawned e.g., a shell
* flag = 2: do not wait in parent for child process e.g. DE file manager
*/
static void static void
spawn(char *file, char *arg, char *dir, int notify) spawn(char *file, char *arg, char *dir, int flag)
{ {
pid_t pid; pid_t pid;
int status; int status;
@ -290,14 +295,16 @@ spawn(char *file, char *arg, char *dir, int notify)
if (pid == 0) { if (pid == 0) {
if (dir != NULL) if (dir != NULL)
status = chdir(dir); status = chdir(dir);
if (notify) if (flag == 1)
fprintf(stdout, "\n +-++-++-+\n | n n n |\n +-++-++-+\n\n"); fprintf(stdout, "\n +-++-++-+\n | n n n |\n +-++-++-+\n\n");
execlp(file, file, arg, NULL); execlp(file, file, arg, NULL);
_exit(1); _exit(1);
} else { } else {
if (flag != 2) {
/* Ignore interruptions */ /* Ignore interruptions */
while (waitpid(pid, &status, 0) == -1) while (waitpid(pid, &status, 0) == -1)
DPRINTF_D(status); DPRINTF_D(status);
}
DPRINTF_D(pid); DPRINTF_D(pid);
} }
} }
@ -937,8 +944,8 @@ show_help(void)
c Show change dir prompt\n\ c Show change dir prompt\n\
d Toggle detail view\n\ d Toggle detail view\n\
D Toggle current file details screen\n\ D Toggle current file details screen\n\
m Show concise mediainfo in less\n\ m Show concise mediainfo\n\
M Show full mediainfo in less\n\ M Show full mediainfo\n\
. Toggle hide .dot files\n\ . Toggle hide .dot files\n\
s Toggle sort by file size\n\ s Toggle sort by file size\n\
S Toggle disk usage analyzer mode\n\ S Toggle disk usage analyzer mode\n\
@ -1618,9 +1625,7 @@ nochange:
goto nochange; goto nochange;
} }
exitcurses(); spawn(desktop_manager, path, path, 2);
spawn(desktop_manager, path, path, 0);
initcurses();
break; break;
case SEL_FSIZE: case SEL_FSIZE:
sizeorder = !sizeorder; sizeorder = !sizeorder;