sbar

sbar - a suckless status bar
git clone git://ssnf.xyz/sbar
Log | Files | Refs

sbar.c (640B)


      1 #include <stdio.h>
      2 #include <time.h>
      3 
      4 #include "sbar.h"
      5 #include "config.h"
      6 
      7 typedef struct {
      8 	char text[18];
      9 	uint s;
     10 } Date;
     11 
     12 Bat		bat;
     13 Date	date;
     14 Ram		ram;
     15 Title	title;
     16 
     17 static void Datechk();
     18 
     19 static void
     20 Datechk()
     21 {
     22 	struct tm* tm;
     23 	time_t     t;
     24 
     25 	t = time(NULL);
     26 	tm = localtime(&t);
     27 	if (tm->tm_sec == date.s)
     28 		return;
     29 	date.s = tm->tm_sec;
     30 	strftime(date.text, 18, datefmt, tm);
     31 	++title.update;
     32 }
     33 
     34 int
     35 main()
     36 {
     37 	Partinit();
     38 	Raminit();
     39 	Titleinit();
     40 	for (;;) {
     41 		Partchk();
     42 		Ramchk();
     43 		Datechk();
     44 		Batchk();
     45 		if (title.update) {
     46 			title.update = 0;
     47 			snprintf(title.text, 256, FMT);
     48 			Titleset();
     49 		}
     50 		wait(wtime);
     51 	}
     52 }