diff options
Diffstat (limited to 'commands.c')
-rw-r--r-- | commands.c | 66 |
1 files changed, 0 insertions, 66 deletions
@@ -504,69 +504,3 @@ bool it_toggle_alpha(arg_t a) return true; } -bool it_open_with(arg_t a) -{ - const char *prog = (const char*) a; - pid_t pid; - - if (prog == NULL || *prog == '\0') - return false; - - if ((pid = fork()) == 0) { - execlp(prog, prog, - files[mode == MODE_IMAGE ? fileidx : tns.sel].path, NULL); - warn("could not exec: %s", prog); - exit(EXIT_FAILURE); - } else if (pid < 0) { - warn("could not fork. program was: %s", prog); - } - return false; -} - -bool it_shell_cmd(arg_t a) -{ - int n, status; - const char *cmdline = (const char*) a; - pid_t pid; - - if (cmdline == NULL || *cmdline == '\0') - return false; - - n = mode == MODE_IMAGE ? fileidx : tns.sel; - - if (setenv("SXIV_IMG", files[n].path, 1) < 0) { - warn("could not set env.-variable: SXIV_IMG. command line was: %s", - cmdline); - return false; - } - - if ((pid = fork()) == 0) { - execl("/bin/sh", "/bin/sh", "-c", cmdline, NULL); - warn("could not exec: /bin/sh. command line was: %s", cmdline); - exit(EXIT_FAILURE); - } else if (pid < 0) { - warn("could not fork. command line was: %s", cmdline); - return false; - } - - win_set_cursor(&win, CURSOR_WATCH); - - waitpid(pid, &status, 0); - if (WIFEXITED(status) == 0 || WEXITSTATUS(status) != 0) - warn("child exited with non-zero return value: %d. command line was: %s", - WEXITSTATUS(status), cmdline); - - if (mode == MODE_IMAGE) { - img_close(&img, true); - load_image(fileidx); - } - if (!tns_load(&tns, n, &files[n], true, mode == MODE_IMAGE) && - mode == MODE_THUMB) - { - remove_file(tns.sel, false); - tns.dirty = true; - if (tns.sel >= tns.cnt) - tns.sel = tns.cnt - 1; - } - return true; -} |