-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
41 lines (34 loc) · 1.05 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <X11/xpm.h>
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <string.h>
#include "vroot.h"
int main(){
Display *dpy;
Window root;
GC g;
XWindowAttributes wa;
XImage *cows;
int cownum;
dpy = XOpenDisplay(getenv("DISPLAY"));
root = DefaultRootWindow(dpy);
g = XCreateGC (dpy, root, 0, NULL);
if(XpmReadFileToImage(dpy, "cow.xpm", &cows, NULL, NULL)){
printf("whoops! you have to put the cd, in your computer.\n");
exit(1);
}
XSetForeground(dpy, g, WhitePixelOfScreen(DefaultScreenOfDisplay(dpy)));
while(1){
cownum = random()&52;
char stringthing[30] = "cows/FUNNY";
strcat(stringthing, itoa(cownum));
strcat(stringthing, ".xpm");
XpmReadFileToImage(dpy, stringthing, &cows, NULL, NULL);
XPutImage(dpy, root, g, cows, 0, 0, XDisplayWidth(dpy, root) / 2, XDisplayHeight(dpy, root) / 2, cows->width, cows->height);
//XClearWindow(dpy, root);
XFlush(dpy);
usleep(1000);
}
XCloseDisplay(dpy);
}