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
^T | Toggle path quote
^L | Redraw, clear prompt
L | Lock terminal (on Linux)
? | Help, settings
Q, ^G | Quit and cd
q, ^X | Quit

2
nnn.1
View File

@ -112,6 +112,8 @@ Toggle multiple file path copy mode
Toggle path quote
.It Ic ^L
Force a redraw, clear rename or filter prompt
.It Ic L
Lock terminal (Linux only)
.It Ic \&?
Toggle help and settings screen
.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^T | Toggle path quote\n"
"d^L | Redraw, clear prompt\n"
#ifdef __linux__
"eL | Lock terminal\n"
#endif
"e? | Help, settings\n"
"aQ, ^G | Quit and cd\n"
"aq, ^X | Quit\n\n");
@ -3208,6 +3211,11 @@ nochange:
run = xgetenv(env, run);
spawn(run, dents[cur].name, NULL, path, F_NORMAL);
break;
#ifdef __linux__
case SEL_LOCK:
spawn(player, "", "screensaver", NULL, F_NORMAL | F_SIGINT);
break;
#endif
case SEL_CDQUIT:
{
char *tmpfile = "/tmp/nnn";

11
nnn.h
View File

@ -44,6 +44,9 @@ enum action {
SEL_RUN,
SEL_RUNSCRIPT,
SEL_RUNARG,
#ifdef __linux__
SEL_LOCK,
#endif
SEL_CDQUIT,
SEL_QUIT,
};
@ -135,9 +138,9 @@ static struct key bindings[] = {
/* Open dir in desktop file manager */
{ 'o', SEL_DFB, "", "" },
/* List archive */
{ 'F', SEL_LIST, "-l", "" },
{ 'F', SEL_LIST, "-l", "" },
/* Extract archive */
{ CONTROL('F'), SEL_EXTRACT, "-x", "" },
{ CONTROL('F'), SEL_EXTRACT, "-x", "" },
/* Toggle sort by size */
{ 's', SEL_FSIZE, "", "" },
/* Sort by total block count including dir contents */
@ -173,6 +176,10 @@ static struct key bindings[] = {
/* Run command with argument */
{ 'e', SEL_RUNARG, "vi", "EDITOR" },
{ 'p', SEL_RUNARG, "less", "PAGER" },
#ifdef __linux__
/* Lock screen */
{ 'L', SEL_LOCK, "", "" },
#endif
/* Change dir on quit */
{ 'Q', SEL_CDQUIT, "", "" },
{ CONTROL('G'), SEL_CDQUIT, "", "" },