33 lines
511 B
C
33 lines
511 B
C
#include <X11/Xlib.h>
|
|
#include <stdio.h>
|
|
#include <time.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
|
|
void show(struct tm *tm)
|
|
{
|
|
char s[6];
|
|
strftime(s, sizeof(s), "%H:%M", tm);
|
|
printf("%s\n", s);
|
|
fflush(stdout);
|
|
}
|
|
|
|
int main() {
|
|
int h, m, init = 60;
|
|
time_t t;
|
|
struct tm *tm;
|
|
|
|
while (1) {
|
|
t = time(NULL);
|
|
tm = localtime(&t);
|
|
if (tm->tm_hour != h || tm->tm_min != m || init > 0) {
|
|
show(tm);
|
|
h = tm->tm_hour;
|
|
m = tm->tm_min;
|
|
init = (init > 0) ? init - 1 : 0;
|
|
}
|
|
sleep(1);
|
|
}
|
|
return 1;
|
|
}
|