mirror of
https://github.com/jarun/nnn.git
synced 2024-12-01 02:49:44 +00:00
Run screensaver after a period of idleness
This commit is contained in:
parent
c5283392fb
commit
1e18b85e56
|
@ -3,6 +3,8 @@
|
||||||
#define EMPTY " "
|
#define EMPTY " "
|
||||||
|
|
||||||
int mtimeorder = 0; /* Set to 1 to sort by time in the default case */
|
int mtimeorder = 0; /* Set to 1 to sort by time in the default case */
|
||||||
|
int idletimeout = 0; /* Screensaver timeout in seconds, 0 to disable */
|
||||||
|
char *idlecmd = "rain"; /* The screensaver program */
|
||||||
|
|
||||||
struct assoc assocs[] = {
|
struct assoc assocs[] = {
|
||||||
{ "\\.(avi|mp4|mkv|mp3|ogg|flac|mov)$", "mplayer" },
|
{ "\\.(avi|mp4|mkv|mp3|ogg|flac|mov)$", "mplayer" },
|
||||||
|
|
13
noice.c
13
noice.c
|
@ -82,6 +82,7 @@ struct entry *dents;
|
||||||
int n, cur;
|
int n, cur;
|
||||||
char *path, *oldpath;
|
char *path, *oldpath;
|
||||||
char *fltr;
|
char *fltr;
|
||||||
|
int idle;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Layout:
|
* Layout:
|
||||||
|
@ -259,6 +260,7 @@ initcurses(void)
|
||||||
intrflush(stdscr, FALSE);
|
intrflush(stdscr, FALSE);
|
||||||
keypad(stdscr, TRUE);
|
keypad(stdscr, TRUE);
|
||||||
curs_set(FALSE); /* Hide cursor */
|
curs_set(FALSE); /* Hide cursor */
|
||||||
|
timeout(1000); /* One second */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -314,6 +316,10 @@ nextsel(char **run)
|
||||||
int c, i;
|
int c, i;
|
||||||
|
|
||||||
c = getch();
|
c = getch();
|
||||||
|
if (c == -1)
|
||||||
|
idle++;
|
||||||
|
else
|
||||||
|
idle = 0;
|
||||||
|
|
||||||
for (i = 0; i < LEN(bindings); i++)
|
for (i = 0; i < LEN(bindings); i++)
|
||||||
if (c == bindings[i].sym) {
|
if (c == bindings[i].sym) {
|
||||||
|
@ -879,6 +885,13 @@ moretyping:
|
||||||
initcurses();
|
initcurses();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/* Screensaver */
|
||||||
|
if (idletimeout != 0 && idle == idletimeout) {
|
||||||
|
idle = 0;
|
||||||
|
exitcurses();
|
||||||
|
spawn(idlecmd, NULL, NULL);
|
||||||
|
initcurses();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue