From: Jann Horn Date: Tue, 7 Jul 2015 14:06:53 +0000 (+0200) Subject: initial X-Git-Url: http://git.thejh.net/?a=commitdiff_plain;h=d994ec4befe1c44c321463d9892fe351f69bb9dc;p=sleepy.git initial --- d994ec4befe1c44c321463d9892fe351f69bb9dc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..12136b4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +sleepy diff --git a/sleepy.c b/sleepy.c new file mode 100644 index 0000000..7c871e8 --- /dev/null +++ b/sleepy.c @@ -0,0 +1,15 @@ +#include + +int main(void) { + time_t last = 0; + while(1) { + sleep(30); + time_t unixtime = time(NULL); + if (unixtime - last < 300) continue; + struct tm *t = localtime(&unixtime); + if (t->tm_hour >= 5 && t->tm_hour != 23) continue; + if (t->tm_min % 15 != 0) continue; + system("sstandby"); + last = unixtime; + } +}