Support screen locking on Linux

This commit is contained in:
Arun Prakash Jana 2018-03-30 21:23:28 +05:30
parent 1e1708c2ec
commit 3a515585d1
No known key found for this signature in database
GPG key ID: A75979F35C080412
4 changed files with 20 additions and 2 deletions

View file

@ -242,6 +242,7 @@ optional arguments:
^Y | Toggle multi-copy mode ^Y | Toggle multi-copy mode
^T | Toggle path quote ^T | Toggle path quote
^L | Redraw, clear prompt ^L | Redraw, clear prompt
L | Lock terminal (on Linux)
? | Help, settings ? | Help, settings
Q, ^G | Quit and cd Q, ^G | Quit and cd
q, ^X | Quit q, ^X | Quit

2
nnn.1
View file

@ -112,6 +112,8 @@ Toggle multiple file path copy mode
Toggle path quote Toggle path quote
.It Ic ^L .It Ic ^L
Force a redraw, clear rename or filter prompt Force a redraw, clear rename or filter prompt
.It Ic L
Lock terminal (Linux only)
.It Ic \&? .It Ic \&?
Toggle help and settings screen Toggle help and settings screen
.It Ic Q, ^G .It Ic Q, ^G

8
nnn.c
View file

@ -1968,6 +1968,9 @@ show_help(char *path)
"d^Y | Toggle multi-copy mode\n" "d^Y | Toggle multi-copy mode\n"
"d^T | Toggle path quote\n" "d^T | Toggle path quote\n"
"d^L | Redraw, clear prompt\n" "d^L | Redraw, clear prompt\n"
#ifdef __linux__
"eL | Lock terminal\n"
#endif
"e? | Help, settings\n" "e? | Help, settings\n"
"aQ, ^G | Quit and cd\n" "aQ, ^G | Quit and cd\n"
"aq, ^X | Quit\n\n"); "aq, ^X | Quit\n\n");
@ -3208,6 +3211,11 @@ nochange:
run = xgetenv(env, run); run = xgetenv(env, run);
spawn(run, dents[cur].name, NULL, path, F_NORMAL); spawn(run, dents[cur].name, NULL, path, F_NORMAL);
break; break;
#ifdef __linux__
case SEL_LOCK:
spawn(player, "", "screensaver", NULL, F_NORMAL | F_SIGINT);
break;
#endif
case SEL_CDQUIT: case SEL_CDQUIT:
{ {
char *tmpfile = "/tmp/nnn"; char *tmpfile = "/tmp/nnn";

7
nnn.h
View file

@ -44,6 +44,9 @@ enum action {
SEL_RUN, SEL_RUN,
SEL_RUNSCRIPT, SEL_RUNSCRIPT,
SEL_RUNARG, SEL_RUNARG,
#ifdef __linux__
SEL_LOCK,
#endif
SEL_CDQUIT, SEL_CDQUIT,
SEL_QUIT, SEL_QUIT,
}; };
@ -173,6 +176,10 @@ static struct key bindings[] = {
/* Run command with argument */ /* Run command with argument */
{ 'e', SEL_RUNARG, "vi", "EDITOR" }, { 'e', SEL_RUNARG, "vi", "EDITOR" },
{ 'p', SEL_RUNARG, "less", "PAGER" }, { 'p', SEL_RUNARG, "less", "PAGER" },
#ifdef __linux__
/* Lock screen */
{ 'L', SEL_LOCK, "", "" },
#endif
/* Change dir on quit */ /* Change dir on quit */
{ 'Q', SEL_CDQUIT, "", "" }, { 'Q', SEL_CDQUIT, "", "" },
{ CONTROL('G'), SEL_CDQUIT, "", "" }, { CONTROL('G'), SEL_CDQUIT, "", "" },