Add option -e to use exiftool

This commit is contained in:
Arun Prakash Jana 2017-07-02 23:57:41 +05:30
parent acdc6dc0a3
commit 2b963634bc
No known key found for this signature in database
GPG Key ID: A75979F35C080412
4 changed files with 41 additions and 34 deletions

View File

@ -79,7 +79,7 @@ Have fun with it! PRs are welcome. Check out [#1](https://github.com/jarun/nnn/i
- Information
- Basic and detail view
- Detailed file information
- Media information (needs mediainfo)
- Media information (needs mediainfo or exiftool, if specified)
- Ordering
- Numeric order (1, 2, ... 10, 11, ...) for numeric names
- Sort by modification time, size
@ -140,8 +140,9 @@ Have fun with it! PRs are welcome. Check out [#1](https://github.com/jarun/nnn/i
PATH directory to open [default: current dir]
optional arguments:
-l start in light mode (fewer details)
-e use exiftool instead of mediainfo
-i start in navigate-as-you-type mode
-l start in light mode (fewer details)
-n disable color for directory entries
-p path to custom nlay
-S start in disk usage analyzer mode
@ -228,7 +229,7 @@ The following abbreviations are used in the detail view:
export NNN_DE_FILE_MANAGER=thunar
export NNN_DE_FILE_MANAGER=nautilus
- [mediainfo](https://mediaarea.net/en/MediaInfo) is required to view media information
- [mediainfo](https://mediaarea.net/en/MediaInfo) (or exiftool, if specified) is required to view media information
#### Help

View File

@ -120,10 +120,10 @@ static struct key bindings[] = {
{ 'd', SEL_DETAIL, "", "" },
/* File details */
{ 'D', SEL_STATS, "", "" },
/* Show mediainfo short */
{ 'm', SEL_MEDIA, "", "" },
/* Show mediainfo full */
{ 'M', SEL_FMEDIA, "", "" },
/* Show media info short, run is hacked */
{ 'm', SEL_MEDIA, NULL, "" },
/* Show media info full, run is hacked */
{ 'M', SEL_FMEDIA, "-f", "" },
/* Open dir in desktop file manager */
{ 'o', SEL_DFB, "", "" },
/* Toggle sort by size */

7
nnn.1
View File

@ -101,12 +101,15 @@ directory you came out of.
.Nm
supports the following options:
.Pp
.Fl l
start in light mode (fewer details)
.Fl e
use exiftool instead of mediainfo
.Pp
.Fl i
start in navigate-as-you-type mode
.Pp
.Fl l
start in light mode (fewer details)
.Pp
.Fl n
disable color for directory entries
.Pp

39
nnn.c
View File

@ -180,15 +180,19 @@ static const double div_2_pow_10 = 1.0 / 1024.0;
static uint _WSHIFT;
/* Utilities to open files, run actions */
static char *utils[] = {
static char * const utils[] = {
#ifdef __APPLE__
"/usr/bin/open",
#else
"/usr/bin/xdg-open",
#endif
"nlay"
"nlay",
"mediainfo",
"exiftool"
};
static char *metaviewer;
/* For use in functions which are isolated and don't return the buffer */
static char g_buf[MAX_CMD_LEN];
@ -1440,11 +1444,11 @@ show_stats(char *fpath, char *fname, struct stat *sb)
static int
show_mediainfo(char *fpath, char *arg)
{
if (!get_output(g_buf, MAX_CMD_LEN, "which", "mediainfo", NULL, 0))
if (!get_output(g_buf, MAX_CMD_LEN, "which", metaviewer, NULL, 0))
return -1;
exitcurses();
get_output(NULL, 0, "mediainfo", fpath, arg, 1);
get_output(NULL, 0, metaviewer, fpath, arg, 1);
initcurses();
return 0;
}
@ -2360,23 +2364,14 @@ nochange:
break;
}
case SEL_MEDIA:
if (ndents > 0) {
mkpath(path, dents[cur].name, oldpath,
PATH_MAX);
if (show_mediainfo(oldpath, NULL) == -1) {
printmsg("mediainfo missing");
goto nochange;
}
}
break;
case SEL_FMEDIA:
if (ndents > 0) {
mkpath(path, dents[cur].name, oldpath,
PATH_MAX);
if (show_mediainfo(oldpath, "-f") == -1) {
printmsg("mediainfo missing");
if (show_mediainfo(oldpath, run) == -1) {
sprintf(g_buf, "%s missing", metaviewer);
printmsg(g_buf);
goto nochange;
}
}
@ -2470,8 +2465,9 @@ The missing terminal file browser for X.\n\n\
positional arguments:\n\
PATH directory to open [default: current dir]\n\n\
optional arguments:\n\
-l start in light mode (fewer details)\n\
-e use exiftool instead of mediainfo\n\
-i start in navigate-as-you-type mode\n\
-l start in light mode (fewer details)\n\
-n disable color for directory entries\n\
-p path to custom nlay\n\
-S start in disk usage analyzer mode\n\
@ -2497,7 +2493,7 @@ main(int argc, char *argv[])
exit(1);
}
while ((opt = getopt(argc, argv, "lSinp:vh")) != -1) {
while ((opt = getopt(argc, argv, "lSinep:vh")) != -1) {
switch (opt) {
case 'S':
cfg.blkorder = 1;
@ -2512,6 +2508,9 @@ main(int argc, char *argv[])
case 'n':
cfg.showcolor = 0;
break;
case 'e':
metaviewer = utils[3];
break;
case 'p':
player = optarg;
break;
@ -2560,6 +2559,10 @@ main(int argc, char *argv[])
if (getenv("NNN_USE_EDITOR"))
editor = xgetenv("EDITOR", "vi");
/* Set metadata viewer if not set */
if (!metaviewer)
metaviewer = utils[2];
/* Set player if not set already */
if (!player)
player = utils[1];