aboutsummaryrefslogtreecommitdiffstats
path: root/noice.c
diff options
context:
space:
mode:
authorGravatar lostd <lostd@2f30.org>2015-11-02 03:21:41 +0200
committerGravatar lostd <lostd@2f30.org>2015-11-02 03:21:41 +0200
commit1e18b85e56d98ca2daeb7adc587c28f5d653a01f (patch)
tree0d7c73f0b2ecdf91975addf7e87fbfba734e8ac5 /noice.c
parentc5283392fbf14c3a94be6b04e2561a14e9ec98df (diff)
downloadnnn-1e18b85e56d98ca2daeb7adc587c28f5d653a01f.tar.gz
Run screensaver after a period of idleness
Diffstat (limited to 'noice.c')
-rw-r--r--noice.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/noice.c b/noice.c
index ba529d6..18577d3 100644
--- a/noice.c
+++ b/noice.c
@@ -82,6 +82,7 @@ struct entry *dents;
int n, cur;
char *path, *oldpath;
char *fltr;
+int idle;
/*
* Layout:
@@ -259,6 +260,7 @@ initcurses(void)
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
curs_set(FALSE); /* Hide cursor */
+ timeout(1000); /* One second */
}
void
@@ -314,6 +316,10 @@ nextsel(char **run)
int c, i;
c = getch();
+ if (c == -1)
+ idle++;
+ else
+ idle = 0;
for (i = 0; i < LEN(bindings); i++)
if (c == bindings[i].sym) {
@@ -879,6 +885,13 @@ moretyping:
initcurses();
break;
}
+ /* Screensaver */
+ if (idletimeout != 0 && idle == idletimeout) {
+ idle = 0;
+ exitcurses();
+ spawn(idlecmd, NULL, NULL);
+ initcurses();
+ }
}
}