add lupan-wm and lupan-clock and use them if available
This commit is contained in:
2
lupan-clock/Makefile
Normal file
2
lupan-clock/Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
lupan-clock: lupan-clock.c
|
||||
${CC} -o $@ $< -lX11 -Wall
|
44
lupan-clock/lupan-clock.c
Normal file
44
lupan-clock/lupan-clock.c
Normal file
@ -0,0 +1,44 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
static void die(const char *errstr);
|
||||
|
||||
void die(const char *errstr) {
|
||||
fputs(errstr, stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void show(Display *dpy, int root, struct tm *tm)
|
||||
{
|
||||
char s[6];
|
||||
strftime(s, sizeof(s), "%H:%M", tm);
|
||||
XStoreName(dpy, root, s);
|
||||
XSync(dpy, True);
|
||||
}
|
||||
|
||||
int main() {
|
||||
Display *dpy;
|
||||
int root, h, m, init = 60;
|
||||
time_t t;
|
||||
struct tm *tm;
|
||||
|
||||
if (!(dpy = XOpenDisplay(NULL)))
|
||||
die("lupan-clock: cannot open display\n");
|
||||
root = DefaultRootWindow(dpy);
|
||||
while (1) {
|
||||
t = time(NULL);
|
||||
tm = localtime(&t);
|
||||
if (tm->tm_hour != h || tm->tm_min != m || init > 0) {
|
||||
show(dpy, root, tm);
|
||||
h = tm->tm_hour;
|
||||
m = tm->tm_min;
|
||||
init = (init > 0) ? init - 1 : 0;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
return 1;
|
||||
}
|
Reference in New Issue
Block a user