mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 20:01:27 +00:00
Use macros for external utils
This commit is contained in:
parent
ee733a39b1
commit
58e27fb2de
26
nnn.c
26
nnn.c
|
@ -271,6 +271,14 @@ static uint KQUEUE_FFLAGS = NOTE_DELETE | NOTE_EXTEND | NOTE_LINK | NOTE_RENAME
|
||||||
static struct timespec gtimeout;
|
static struct timespec gtimeout;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Macros for utilities */
|
||||||
|
#define MEDIAINFO 0
|
||||||
|
#define EXIFTOOL 1
|
||||||
|
#define OPENER 2
|
||||||
|
#define NLAY 3
|
||||||
|
#define ATOOL 4
|
||||||
|
#define VIDIR 5
|
||||||
|
|
||||||
/* Utilities to open files, run actions */
|
/* Utilities to open files, run actions */
|
||||||
static char * const utils[] = {
|
static char * const utils[] = {
|
||||||
"mediainfo",
|
"mediainfo",
|
||||||
|
@ -1811,14 +1819,14 @@ show_mediainfo(char *fpath, char *arg)
|
||||||
static int
|
static int
|
||||||
handle_archive(char *fpath, char *arg, char *dir)
|
handle_archive(char *fpath, char *arg, char *dir)
|
||||||
{
|
{
|
||||||
if (!get_output(g_buf, MAX_CMD_LEN, "which", utils[4], NULL, 0))
|
if (!get_output(g_buf, MAX_CMD_LEN, "which", utils[ATOOL], NULL, 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (arg[1] == 'x')
|
if (arg[1] == 'x')
|
||||||
spawn(utils[4], arg, fpath, dir, F_NORMAL);
|
spawn(utils[ATOOL], arg, fpath, dir, F_NORMAL);
|
||||||
else {
|
else {
|
||||||
exitcurses();
|
exitcurses();
|
||||||
get_output(NULL, 0, utils[4], arg, fpath, 1);
|
get_output(NULL, 0, utils[ATOOL], arg, fpath, 1);
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2471,7 +2479,7 @@ nochange:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Invoke desktop opener as last resort */
|
/* Invoke desktop opener as last resort */
|
||||||
spawn(utils[2], newpath, NULL, NULL, nowait);
|
spawn(utils[OPENER], newpath, NULL, NULL, nowait);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -2810,7 +2818,7 @@ nochange:
|
||||||
if (sel == SEL_MEDIA || sel == SEL_FMEDIA)
|
if (sel == SEL_MEDIA || sel == SEL_FMEDIA)
|
||||||
xstrlcpy(newpath + 8, utils[cfg.metaviewer], 32);
|
xstrlcpy(newpath + 8, utils[cfg.metaviewer], 32);
|
||||||
else
|
else
|
||||||
xstrlcpy(newpath + 8, utils[4], 32);
|
xstrlcpy(newpath + 8, utils[ATOOL], 32);
|
||||||
|
|
||||||
printmsg(newpath);
|
printmsg(newpath);
|
||||||
goto nochange;
|
goto nochange;
|
||||||
|
@ -3073,7 +3081,7 @@ nochange:
|
||||||
xstrlcpy(oldname, tmp, NAME_MAX + 1);
|
xstrlcpy(oldname, tmp, NAME_MAX + 1);
|
||||||
goto begin;
|
goto begin;
|
||||||
case SEL_RENAMEALL:
|
case SEL_RENAMEALL:
|
||||||
if (!get_output(g_buf, MAX_CMD_LEN, "which", utils[5], NULL, 0)) {
|
if (!get_output(g_buf, MAX_CMD_LEN, "which", utils[VIDIR], NULL, 0)) {
|
||||||
printmsg("vidir missing");
|
printmsg("vidir missing");
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
@ -3091,7 +3099,7 @@ nochange:
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
|
||||||
spawn(utils[5], ".", NULL, NULL, F_NORMAL);
|
spawn(utils[VIDIR], ".", NULL, NULL, F_NORMAL);
|
||||||
|
|
||||||
/* Change back to program start dir */
|
/* Change back to program start dir */
|
||||||
if (chdir(newpath) == -1)
|
if (chdir(newpath) == -1)
|
||||||
|
@ -3202,7 +3210,7 @@ main(int argc, char *argv[])
|
||||||
cfg.color = (uchar)atoi(optarg);
|
cfg.color = (uchar)atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
cfg.metaviewer = 1;
|
cfg.metaviewer = EXIFTOOL;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
player = optarg;
|
player = optarg;
|
||||||
|
@ -3272,7 +3280,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
/* Set player if not set already */
|
/* Set player if not set already */
|
||||||
if (!player)
|
if (!player)
|
||||||
player = utils[3];
|
player = utils[NLAY];
|
||||||
|
|
||||||
/* Get the desktop file browser, if set */
|
/* Get the desktop file browser, if set */
|
||||||
desktop_manager = getenv("NNN_DE_FILE_MANAGER");
|
desktop_manager = getenv("NNN_DE_FILE_MANAGER");
|
||||||
|
|
Loading…
Reference in a new issue