@@ -35,9 +35,10 @@ Noice is Not Noice, a noicer fork... | |||||
- [cd on quit](#cd-on-quit) | - [cd on quit](#cd-on-quit) | ||||
- [customize nlay](#customize-nlay) | - [customize nlay](#customize-nlay) | ||||
- [copy file path to clipboard](#copy-file-path-to-clipboard) | - [copy file path to clipboard](#copy-file-path-to-clipboard) | ||||
- [file copy. move. delete](#file-copy-move-delete) | |||||
- [file copy, move, delete](#file-copy-move-delete) | |||||
- [boost chdir prompt](#boost-chdir-prompt) | - [boost chdir prompt](#boost-chdir-prompt) | ||||
- [change file associations](#change-file-associations) | - [change file associations](#change-file-associations) | ||||
- [set idle timeout](#set-idle-timeout) | |||||
- [Why fork?](#why-fork) | - [Why fork?](#why-fork) | ||||
- [Mentions](#mentions) | - [Mentions](#mentions) | ||||
- [Developers](#developers) | - [Developers](#developers) | ||||
@@ -85,6 +86,7 @@ Have fun with it! PRs are welcome. Check out [#1](https://github.com/jarun/nnn/i | |||||
- Change directory at exit (*easy* shell integration) | - Change directory at exit (*easy* shell integration) | ||||
- Open any file in EDITOR (fallback vi) or PAGER (fallback less) | - Open any file in EDITOR (fallback vi) or PAGER (fallback less) | ||||
- Open current directory in a custom GUI file browser | - Open current directory in a custom GUI file browser | ||||
- Terminal screensaver (default vlock, customizable) integration | |||||
- Unicode support | - Unicode support | ||||
- Highly optimized code, minimal resource usage | - Highly optimized code, minimal resource usage | ||||
@@ -180,8 +182,8 @@ Right, Enter, l, ^M | Open file or enter dir | |||||
^K | Invoke file name copier | ^K | Invoke file name copier | ||||
^L | Force a redraw | ^L | Force a redraw | ||||
? | Toggle help screen | ? | Toggle help screen | ||||
q | Quit | |||||
Q | Quit and change directory | Q | Quit and change directory | ||||
q, ^Q | Quit | |||||
``` | ``` | ||||
#### Filters | #### Filters | ||||
@@ -226,6 +228,7 @@ The following abbreviations are used in the detail view: | |||||
- [zathura](https://pwmt.org/projects/zathura/) - pdf | - [zathura](https://pwmt.org/projects/zathura/) - pdf | ||||
- vim - plain text | - vim - plain text | ||||
- gnome-search-tool - search | - gnome-search-tool - search | ||||
- vlock - terminal screensaver | |||||
- to add, remove recognized extensions in `nnn`, see [how to change file associations](#change-file-associations) | - to add, remove recognized extensions in `nnn`, see [how to change file associations](#change-file-associations) | ||||
- If a file without any extension is a plain text file, it is opened in EDITOR (fallback vi) | - If a file without any extension is a plain text file, it is opened in EDITOR (fallback vi) | ||||
- Set `NNN_FALLBACK_OPENER` as the fallback opener. E.g.: | - Set `NNN_FALLBACK_OPENER` as the fallback opener. E.g.: | ||||
@@ -313,6 +316,10 @@ If you want to add a file extension mainline, please raise a bug. Without it `nn | |||||
nlay has provisions (disabled by default) to handle a specific file extension too. However, the extension should be recognized by `nnn` first. | nlay has provisions (disabled by default) to handle a specific file extension too. However, the extension should be recognized by `nnn` first. | ||||
#### set idle timeout | |||||
The terminal screensaver is disabled by default. To set the wait time in seconds, use environment variable `NNN_IDLE_TIMEOUT`. | |||||
### Why fork? | ### Why fork? | ||||
I chose to fork because: | I chose to fork because: | ||||
@@ -10,7 +10,6 @@ static int bsizeorder = 0; /* Set to 1 to sort by blocks used including content | |||||
static int idletimeout = 0; /* Screensaver timeout in seconds, 0 to disable */ | static int idletimeout = 0; /* Screensaver timeout in seconds, 0 to disable */ | ||||
static int showhidden = 0; /* Set to 1 to show hidden files by default */ | static int showhidden = 0; /* Set to 1 to show hidden files by default */ | ||||
static int showdetail = 0; /* Set to show additional file info */ | static int showdetail = 0; /* Set to show additional file info */ | ||||
static char *idlecmd = "rain"; /* The screensaver program */ | |||||
static struct assoc assocs[] = { | static struct assoc assocs[] = { | ||||
{ "\\.(c|cpp|h|log|md|py|sh|txt)$", "text" }, | { "\\.(c|cpp|h|log|md|py|sh|txt)$", "text" }, | ||||
@@ -23,6 +22,8 @@ static struct assoc assocs[] = { | |||||
static struct key bindings[] = { | static struct key bindings[] = { | ||||
/* Quit */ | /* Quit */ | ||||
{ 'q', SEL_QUIT, "", "" }, | { 'q', SEL_QUIT, "", "" }, | ||||
{ CONTROL('Q'), SEL_QUIT, "", "" }, | |||||
/* Change dir on quit */ | |||||
{ 'Q', SEL_CDQUIT, "", "" }, | { 'Q', SEL_CDQUIT, "", "" }, | ||||
/* Back */ | /* Back */ | ||||
{ KEY_BACKSPACE, SEL_BACK, "", "" }, | { KEY_BACKSPACE, SEL_BACK, "", "" }, | ||||
@@ -59,8 +59,8 @@ ENABLE_FILE_TYPE_HANDLING | |||||
#------------------ AUDIO ------------------- | #------------------ AUDIO ------------------- | ||||
if [ "$2" == "audio" ]; then | if [ "$2" == "audio" ]; then | ||||
app=mpv | app=mpv | ||||
# To start mpv in a window enable audio_opts | |||||
#audio_opts="--no-terminal --force-window" | |||||
# To start mpv in a window enable opts | |||||
#opts="--no-terminal --force-window" | |||||
#bg=">/dev/null 2>&1 &" | #bg=">/dev/null 2>&1 &" | ||||
@@ -68,15 +68,15 @@ if [ "$2" == "audio" ]; then | |||||
killall -9 $app >/dev/null 2>&1 | killall -9 $app >/dev/null 2>&1 | ||||
fi | fi | ||||
eval $app $audio_opts "\"$1\"" $bg | |||||
eval $app $opts "\"$1\"" $bg | |||||
exit 0 | exit 0 | ||||
fi | fi | ||||
#------------------ VIDEO ------------------- | #------------------ VIDEO ------------------- | ||||
if [ "$2" == "video" ]; then | if [ "$2" == "video" ]; then | ||||
app=mpv | app=mpv | ||||
# To start mpv in a window enable video_opts | |||||
#video_opts="--no-terminal --force-window" | |||||
# To start mpv in a window enable opts | |||||
#opts="--no-terminal --force-window" | |||||
#bg=">/dev/null 2>&1 &" | #bg=">/dev/null 2>&1 &" | ||||
@@ -84,50 +84,61 @@ if [ "$2" == "video" ]; then | |||||
killall -9 $app >/dev/null 2>&1 | killall -9 $app >/dev/null 2>&1 | ||||
fi | fi | ||||
eval $app $video_opts "\"$1\"" $bg | |||||
eval $app $opts "\"$1\"" $bg | |||||
exit 0 | exit 0 | ||||
fi | fi | ||||
#------------------ IMAGE ------------------- | #------------------ IMAGE ------------------- | ||||
if [ "$2" == "image" ]; then | if [ "$2" == "image" ]; then | ||||
app=viewnior | app=viewnior | ||||
#image_opts= | |||||
#opts= | |||||
bg=">/dev/null 2>&1 &" | bg=">/dev/null 2>&1 &" | ||||
eval $app $image_opts "\"$1\"" $bg | |||||
eval $app $opts "\"$1\"" $bg | |||||
exit 0 | exit 0 | ||||
fi | fi | ||||
#------------------- PDF -------------------- | #------------------- PDF -------------------- | ||||
if [ "$2" == "pdf" ]; then | if [ "$2" == "pdf" ]; then | ||||
app=zathura | app=zathura | ||||
#pdf_opts= | |||||
#opts= | |||||
bg=">/dev/null 2>&1 &" | bg=">/dev/null 2>&1 &" | ||||
eval $app $pdf_opts "\"$1\"" $bg | |||||
eval $app $opts "\"$1\"" $bg | |||||
exit 0 | exit 0 | ||||
fi | fi | ||||
#---------------- PLAINTEXT ----------------- | #---------------- PLAINTEXT ----------------- | ||||
if [ "$2" == "text" ]; then | if [ "$2" == "text" ]; then | ||||
app=vim | app=vim | ||||
#txt_opts= | |||||
#opts= | |||||
#bg=">/dev/null 2>&1 &" | #bg=">/dev/null 2>&1 &" | ||||
eval $app $txt_opts "\"$1\"" $bg | |||||
eval $app $opts "\"$1\"" $bg | |||||
exit 0 | exit 0 | ||||
fi | fi | ||||
#----------------- SEARCH ------------------- | #----------------- SEARCH ------------------- | ||||
if [ "$2" == "search" ]; then | if [ "$2" == "search" ]; then | ||||
app=gnome-search-tool | app=gnome-search-tool | ||||
#search_opts= | |||||
#opts= | |||||
bg=">/dev/null 2>&1 &" | bg=">/dev/null 2>&1 &" | ||||
eval $app $search_opts --path "\"$1\"" $bg | |||||
eval $app $opts --path "\"$1\"" $bg | |||||
exit 0 | |||||
fi | |||||
#--------------- SCREENSAVER ---------------- | |||||
if [ "$2" == "screensaver" ]; then | |||||
app=vlock | |||||
#opts= | |||||
#bg=">/dev/null 2>&1 &" | |||||
eval $app $opts $bg | |||||
exit 0 | exit 0 | ||||
fi | fi |
@@ -89,10 +89,10 @@ Invoke file name copier | |||||
Force a redraw | Force a redraw | ||||
.It Ic \&? | .It Ic \&? | ||||
Toggle help screen | Toggle help screen | ||||
.It Ic q | |||||
Quit | |||||
.It Ic Q | .It Ic Q | ||||
Quit and change directory | Quit and change directory | ||||
.It Ic q, ^Q | |||||
Quit | |||||
.El | .El | ||||
.Pp | .Pp | ||||
Backing up one directory level will set the cursor position at the | Backing up one directory level will set the cursor position at the | ||||
@@ -180,6 +180,9 @@ Examples: xdg-open, gio open, gvfs-open. | |||||
mime opener to use as a fallback when no association is set for a file | mime opener to use as a fallback when no association is set for a file | ||||
type. Custom associations are listed in the EXAMPLES section below. | type. Custom associations are listed in the EXAMPLES section below. | ||||
.Pp | .Pp | ||||
\fBNNN_IDLE_TIMEOUT:\fR set idle timeout (in seconds) to invoke terminal | |||||
screensaver. | |||||
.Pp | |||||
\fBNNN_COPIER:\fR set to a clipboard copier script. For example, on Linux: | \fBNNN_COPIER:\fR set to a clipboard copier script. For example, on Linux: | ||||
.Bd -literal | .Bd -literal | ||||
------------------------------------- | ------------------------------------- | ||||
@@ -153,6 +153,7 @@ static int ndents, cur, total_dents; | |||||
static int idle; | static int idle; | ||||
static char *opener; | static char *opener; | ||||
static char *fb_opener; | static char *fb_opener; | ||||
static char *nlay="nlay"; | |||||
static char *player; | static char *player; | ||||
static char *copier; | static char *copier; | ||||
static char *desktop_manager; | static char *desktop_manager; | ||||
@@ -330,6 +331,7 @@ all_dots(const char* ptr) | |||||
* - 0b1: draw a marker to indicate nnn spawned e.g., a shell | * - 0b1: draw a marker to indicate nnn spawned e.g., a shell | ||||
* - 0b10: do not wait in parent for child process e.g. DE file manager | * - 0b10: do not wait in parent for child process e.g. DE file manager | ||||
* - 0b100: suppress stdout and stderr | * - 0b100: suppress stdout and stderr | ||||
* - 0b1000: restore default SIGINT handler | |||||
*/ | */ | ||||
static void | static void | ||||
spawn(char *file, char *arg1, char *arg2, char *dir, unsigned char flag) | spawn(char *file, char *arg1, char *arg2, char *dir, unsigned char flag) | ||||
@@ -354,6 +356,8 @@ spawn(char *file, char *arg1, char *arg2, char *dir, unsigned char flag) | |||||
close(fd); | close(fd); | ||||
} | } | ||||
if (flag & 0b1000) | |||||
signal(SIGINT, SIG_DFL); | |||||
execlp(file, file, arg1, arg2, NULL); | execlp(file, file, arg1, arg2, NULL); | ||||
_exit(1); | _exit(1); | ||||
} else { | } else { | ||||
@@ -746,8 +750,8 @@ readln(char *path) | |||||
printprompt(ln); | printprompt(ln); | ||||
break; | break; | ||||
case CONTROL('L'): | case CONTROL('L'): | ||||
cur = oldcur; | |||||
*ch = CONTROL('L'); | |||||
cur = oldcur; // fallthrough | |||||
case CONTROL('Q'): | |||||
goto end; | goto end; | ||||
default: | default: | ||||
wln[len++] = (wchar_t)*ch; | wln[len++] = (wchar_t)*ch; | ||||
@@ -1273,8 +1277,8 @@ show_help(void) | |||||
^K | Invoke file name copier\n\ | ^K | Invoke file name copier\n\ | ||||
^L | Force a redraw\n\ | ^L | Force a redraw\n\ | ||||
? | Toggle help screen\n\ | ? | Toggle help screen\n\ | ||||
q | Quit\n\ | |||||
Q | Quit and change directory\n\n\" | less"); | |||||
Q | Quit and change directory\n\ | |||||
q, ^Q | Quit\n\n\" | less"); | |||||
return system(helpstr); | return system(helpstr); | ||||
} | } | ||||
@@ -1664,10 +1668,7 @@ nochange: | |||||
mime = getmime(dents[cur].name); | mime = getmime(dents[cur].name); | ||||
if (mime) { | if (mime) { | ||||
exitcurses(); | exitcurses(); | ||||
if (player) | |||||
spawn(player, newpath, mime, NULL, 0); | |||||
else | |||||
spawn("nlay", newpath, mime, NULL, 0); | |||||
spawn(player, newpath, mime, NULL, 0); | |||||
initcurses(); | initcurses(); | ||||
continue; | continue; | ||||
} | } | ||||
@@ -1713,10 +1714,7 @@ nochange: | |||||
goto nochange; | goto nochange; | ||||
case SEL_SEARCH: | case SEL_SEARCH: | ||||
exitcurses(); | exitcurses(); | ||||
if (player) | |||||
spawn(player, path, "search", NULL, 0); | |||||
else | |||||
spawn("nlay", path, "search", NULL, 0); | |||||
spawn(player, path, "search", NULL, 0); | |||||
initcurses(); | initcurses(); | ||||
break; | break; | ||||
case SEL_NEXT: | case SEL_NEXT: | ||||
@@ -2085,7 +2083,7 @@ nochange: | |||||
if (idletimeout != 0 && idle == idletimeout) { | if (idletimeout != 0 && idle == idletimeout) { | ||||
idle = 0; | idle = 0; | ||||
exitcurses(); | exitcurses(); | ||||
spawn(idlecmd, NULL, NULL, NULL, 0); | |||||
spawn(player, "", "screensaver", NULL, 8); | |||||
initcurses(); | initcurses(); | ||||
} | } | ||||
} | } | ||||
@@ -2143,7 +2141,7 @@ main(int argc, char *argv[]) | |||||
case 'v': | case 'v': | ||||
fprintf(stdout, "%s\n", VERSION); | fprintf(stdout, "%s\n", VERSION); | ||||
return 0; | return 0; | ||||
case 'h': | |||||
case 'h': // fallthrough | |||||
default: | default: | ||||
usage(); | usage(); | ||||
} | } | ||||
@@ -2171,12 +2169,21 @@ main(int argc, char *argv[]) | |||||
/* Get the default desktop mime opener, if set */ | /* Get the default desktop mime opener, if set */ | ||||
opener = getenv("NNN_OPENER"); | opener = getenv("NNN_OPENER"); | ||||
/* Set player if not set already */ | |||||
if (!player) | |||||
player = nlay; | |||||
/* Get the fallback desktop mime opener, if set */ | /* Get the fallback desktop mime opener, if set */ | ||||
fb_opener = getenv("NNN_FALLBACK_OPENER"); | fb_opener = getenv("NNN_FALLBACK_OPENER"); | ||||
/* 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"); | ||||
/* Get screensaver wait time, if set; copier used as tmp var */ | |||||
copier = getenv("NNN_IDLE_TIMEOUT"); | |||||
if (copier) | |||||
idletimeout = abs(atoi(copier)); | |||||
/* Get the default copier, if set */ | /* Get the default copier, if set */ | ||||
copier = getenv("NNN_COPIER"); | copier = getenv("NNN_COPIER"); | ||||