Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <time.h>
- #include <X11/Xlib.h>
- static Display *dpy;
- void setstatus(char *str) {
- XStoreName(dpy, DefaultRootWindow(dpy), str);
- XSync(dpy, False);
- }
- int getdatetime(char *status, size_t size) {
- time_t result;
- struct tm *resulttm;
- result = time(NULL);
- resulttm = localtime(&result);
- return strftime(status, size, "\x06 %d.%m \x07//\x06 %I:%M ", resulttm);
- }
- int main(void) {
- char status[100];
- int l = 0;
- if (!(dpy = XOpenDisplay(NULL))) {
- fprintf(stderr, "Cannot open display.\n");
- return 1;
- }
- for (;;sleep(2)) {
- l = getdatetime(status, sizeof(status) - l);
- setstatus(status);
- }
- free(status);
- XCloseDisplay(dpy);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment