initial
authorJann Horn <jann@thejh.net>
Tue, 7 Jul 2015 14:06:53 +0000 (16:06 +0200)
committerJann Horn <jann@thejh.net>
Tue, 7 Jul 2015 14:06:53 +0000 (16:06 +0200)
.gitignore [new file with mode: 0644]
sleepy.c [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..12136b4
--- /dev/null
@@ -0,0 +1 @@
+sleepy
diff --git a/sleepy.c b/sleepy.c
new file mode 100644 (file)
index 0000000..7c871e8
--- /dev/null
+++ b/sleepy.c
@@ -0,0 +1,15 @@
+#include <time.h>
+
+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;
+  }
+}