7c871e842f1ccbc63366e901de11e7f5c373dfbd
[sleepy.git] / sleepy.c
1 #include <time.h>
2
3 int main(void) {
4   time_t last = 0;
5   while(1) {
6     sleep(30);
7     time_t unixtime = time(NULL);
8     if (unixtime - last < 300) continue;
9     struct tm *t = localtime(&unixtime);
10     if (t->tm_hour >= 5 && t->tm_hour != 23) continue;
11     if (t->tm_min % 15 != 0) continue;
12     system("sstandby");
13     last = unixtime;
14   }
15 }