]> mj.ucw.cz Git - osdd.git/blobdiff - osdd.c
Cleaned up utility functions and implemented `osd-batt --check-every'
[osdd.git] / osdd.c
diff --git a/osdd.c b/osdd.c
index 15836ea51b7d36377197c5a94fd307bdb16b64e1..f5cd44f776b31819ae9665805aa0329a35a21a63 100644 (file)
--- a/osdd.c
+++ b/osdd.c
@@ -8,20 +8,17 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <inttypes.h>
 #include <poll.h>
 #include <getopt.h>
-#include <sys/time.h>
 #include <xosd.h>
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
 
 #undef DEBUG
-#include "util.h"
+#include "osd.h"
 
 static xosd *osd;
 
-typedef uint64_t timestamp_t;
 static timestamp_t now;
 
 /*** Options ***/
@@ -246,10 +243,7 @@ main(int argc, char **argv)
     {
       pid_t pid = fork();
       if (pid < 0)
-        {
-         fprintf(stderr, "batt: Cannot fork: %m\n");
-         return 1;
-       }
+       die("Cannot fork: %m");
       if (pid > 0)
         return 0;
       setsid();
@@ -274,9 +268,7 @@ main(int argc, char **argv)
 
   for (;;)
     {
-      struct timeval tv;
-      gettimeofday(&tv, NULL);
-      now = (timestamp_t) tv.tv_sec * 1000 + tv.tv_usec / 1000;
+      now = get_current_time();
 
       timestamp_t wait_until = now - 1;
       if (!current_msg && first_msg)