add lupan-wm and lupan-clock and use them if available

This commit is contained in:
2022-01-10 21:38:37 +01:00
parent cbc2fe2b6c
commit 924ac9ccf8
7 changed files with 1018 additions and 5 deletions

2
lupan-clock/Makefile Normal file
View File

@ -0,0 +1,2 @@
lupan-clock: lupan-clock.c
${CC} -o $@ $< -lX11 -Wall

44
lupan-clock/lupan-clock.c Normal file
View 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;
}