config.def.h | 2 ++ noice.c | 13 +++++++++++++ diff --git a/config.def.h b/config.def.h index a355333108195390263411fc771aec6287560516..80cb48c37abb5b69819967a027ae8605250f74ef 100644 --- a/config.def.h +++ b/config.def.h @@ -3,6 +3,8 @@ #define CURSR " > " #define EMPTY " " 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[] = { { "\\.(avi|mp4|mkv|mp3|ogg|flac|mov)$", "mplayer" }, diff --git a/noice.c b/noice.c index ba529d6c325509d04b8fe4d8cbdeaeb9a9feba37..18577d3888c96e29054fb37b93cb3d824cb10c98 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 @@ nonl(); intrflush(stdscr, FALSE); keypad(stdscr, TRUE); curs_set(FALSE); /* Hide cursor */ + timeout(1000); /* One second */ } void @@ -314,6 +316,10 @@ { int c, i; c = getch(); + if (c == -1) + idle++; + else + idle = 0; for (i = 0; i < LEN(bindings); i++) if (c == bindings[i].sym) { @@ -878,6 +884,13 @@ exitcurses(); spawn(run, name, path); initcurses(); break; + } + /* Screensaver */ + if (idletimeout != 0 && idle == idletimeout) { + idle = 0; + exitcurses(); + spawn(idlecmd, NULL, NULL); + initcurses(); } } }