/* mkwall.c : The de-facto sayachan network wallpaper generator. (C)2015-2017 Marisa Kirisame, UnSX Team. For personal use mostly. Released under the GNU GPLv3 (or any later version). Please refer to for license terms. */ #include #include #include #include #include #include #include #include /* TODO: - Option to put waifu on all screens - Find a faster library for imaging - Use xcb instead of Xlib */ /* helper macro for linear interpolation */ #define lerp(a,b,t) ((1.f-(t))*(a)+(t)*(b)) /* a BGRA pixel (packed just in case, even if pointless) */ typedef struct { unsigned char b,g,r,a; } __attribute__((packed)) pixel_t; /* generate a BGRA8 image filled with a 4x4 diagonal stripe pattern interpolating between two specific colours */ void* generate_diag( int w, int h, pixel_t cup, pixel_t cdn ) { const float stripe[4] = {0.625f,0.375f,0.f,1.f}; int x, y, i; pixel_t *diag = malloc(sizeof(pixel_t)*w*h); i = 0; for ( y=0; y " " \n",basename(argv[0])); return 1; } Display *d = XOpenDisplay(0); Screen *s = ScreenOfDisplay(d,DefaultScreen(d)); int rw = s->width, rh = s->height; Imlib_Image wall, waifu; tick = clock(); waifu = imlib_load_image(argv[1]); if ( !waifu ) return 2; tock = clock(); printf("load waifu: %fs\n",(double)(tock-tick)/CLOCKS_PER_SEC); imlib_context_set_image(waifu); int ww = imlib_image_get_width(), wh = imlib_image_get_height(); pixel_t cup, cdn; /* read the hex RGB8 gradient colours */ sscanf(argv[2],"%02hhx%02hhx%02hhx",&cup.r,&cup.g,&cup.b); sscanf(argv[3],"%02hhx%02hhx%02hhx",&cdn.r,&cdn.g,&cdn.b); tick = clock(); wall = imlib_create_image_using_data(rw,rh, generate_diag(rw,rh,cup,cdn)); tock = clock(); printf("generate diag: %fs\n",(double)(tock-tick)/CLOCKS_PER_SEC); imlib_context_set_image(wall); /* get the specified screen geometry if xinerama is active, otherwise just use the full virtual screen */ int sw, sh, ox = 0, oy = 0; int dummy1, dummy2; if ( XineramaQueryExtension(d,&dummy1,&dummy2) && XineramaIsActive(d) ) { printf("xinerama active, querying...\n"); int nxs, sno; XineramaScreenInfo *xs = XineramaQueryScreens(d,&nxs); sscanf(argv[5],"%d",&sno); if ( (nxs+sno) < 0 ) sno = 0; if ( sno >= nxs ) sno = nxs-1; if ( sno < 0 ) sno = nxs+sno; printf("%d screens available, #%d selected\n",nxs,sno); for ( int i=0; i