#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <inttypes.h>
#include <poll.h>
#include <getopt.h>
-#include <sys/time.h>
+#include <locale.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 ***/
static char *default_color = "green";
static char *default_outline_color = "black";
static int default_duration = 1000;
-static int default_min_duration = 1000;
+static int default_min_duration = 250;
static int debug_mode;
static const char short_opts[] = "c:d:Df:l:m:o:";
main(int argc, char **argv)
{
parse_opts(argc, argv);
+ setlocale(LC_CTYPE, "");
XInitThreads();
Display *dpy = XOpenDisplay(NULL);
{
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();
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)