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 - Information
- Basic and detail view - Basic and detail view
- Detailed file information - Detailed file information
- Media information (needs mediainfo) - Media information (needs mediainfo or exiftool, if specified)
- Ordering - Ordering
- Numeric order (1, 2, ... 10, 11, ...) for numeric names - Numeric order (1, 2, ... 10, 11, ...) for numeric names
- Sort by modification time, size - 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] PATH directory to open [default: current dir]
optional arguments: optional arguments:
-l start in light mode (fewer details) -e use exiftool instead of mediainfo
-i start in navigate-as-you-type mode -i start in navigate-as-you-type mode
-l start in light mode (fewer details)
-n disable color for directory entries -n disable color for directory entries
-p path to custom nlay -p path to custom nlay
-S start in disk usage analyzer mode -S start in disk usage analyzer mode
@ -174,8 +175,8 @@ Right, Enter, l, ^M | Open file or enter dir
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 m | Show concise media info
M | Show full mediainfo M | Show full media info
s | Toggle sort by file size s | Toggle sort by file size
S | Toggle disk usage analyzer mode S | Toggle disk usage analyzer mode
t | Toggle sort by modified time t | Toggle sort by modified time
@ -228,7 +229,7 @@ The following abbreviations are used in the detail view:
export NNN_DE_FILE_MANAGER=thunar export NNN_DE_FILE_MANAGER=thunar
export NNN_DE_FILE_MANAGER=nautilus 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 #### Help

View file

@ -120,16 +120,16 @@ static struct key bindings[] = {
{ 'd', SEL_DETAIL, "", "" }, { 'd', SEL_DETAIL, "", "" },
/* File details */ /* File details */
{ 'D', SEL_STATS, "", "" }, { 'D', SEL_STATS, "", "" },
/* Show mediainfo short */ /* Show media info short, run is hacked */
{ 'm', SEL_MEDIA, "", "" }, { 'm', SEL_MEDIA, NULL, "" },
/* Show mediainfo full */ /* Show media info full, run is hacked */
{ 'M', SEL_FMEDIA, "", "" }, { 'M', SEL_FMEDIA, "-f", "" },
/* Open dir in desktop file manager */ /* Open dir in desktop file manager */
{ 'o', SEL_DFB, "", "" }, { 'o', SEL_DFB, "", "" },
/* Toggle sort by size */ /* Toggle sort by size */
{ 's', SEL_FSIZE, "", "" }, { 's', SEL_FSIZE, "", "" },
/* Sort by total block count including dir contents */ /* Sort by total block count including dir contents */
{ 'S', SEL_BSIZE, "", "" }, { 'S', SEL_BSIZE, "", "" },
/* Toggle sort by time */ /* Toggle sort by time */
{ 't', SEL_MTIME, "", "" }, { 't', SEL_MTIME, "", "" },
{ CONTROL('L'), SEL_REDRAW, "", "" }, { CONTROL('L'), SEL_REDRAW, "", "" },

11
nnn.1
View file

@ -66,9 +66,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 Show concise media info
.It Ic M .It Ic M
Show full mediainfo Show full media info
.It Ic s .It Ic s
Toggle sort by file size Toggle sort by file size
.It Ic S .It Ic S
@ -101,12 +101,15 @@ directory you came out of.
.Nm .Nm
supports the following options: supports the following options:
.Pp .Pp
.Fl l .Fl e
start in light mode (fewer details) use exiftool instead of mediainfo
.Pp .Pp
.Fl i .Fl i
start in navigate-as-you-type mode start in navigate-as-you-type mode
.Pp .Pp
.Fl l
start in light mode (fewer details)
.Pp
.Fl n .Fl n
disable color for directory entries disable color for directory entries
.Pp .Pp

43
nnn.c
View file

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