diff --git a/CHANGELOG b/CHANGELOG index e830f33..a3c40b4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,8 +1,19 @@ Version 0.9 + +2005-05-18: + + * added -bg image: + - name - name of the image + - scale - scaling image + - center - centering image + - tile - tile image + - color= - use as bg-color for centering + + 2005-05-17: - * restructuring almost done, polished interface; - - working -bg, -auth and -cursor with all the submodules + * restructuring almost done, polished interface: + : working -bg, -auth and -cursor with all the submodules - cleaned -h - complete -flag - parsing * added -cursor font:list and -cursor theme:list diff --git a/SConstruct b/SConstruct index ed95805..cba04cb 100644 --- a/SConstruct +++ b/SConstruct @@ -22,6 +22,7 @@ alock_options.AddOptions( BoolOption('pam', 'support for pam', 1), BoolOption('hash', 'support for hashs(sha1,md5)', 1), + BoolOption('imlib2', 'support imagereading via imlib2', 1), BoolOption('xcursor', 'support xcursor-themes', 1), BoolOption('amd5', 'build a little md5-helper', 0), @@ -51,6 +52,12 @@ alock_env.AppendUnique( LIBPATH = ['/usr/X11R6/lib'], LIBS = [ 'X11' ]) +conf = alock_env.Configure() +if not conf.CheckLibWithHeader('X11', 'X11/Xlib.h', 'C', 'XOpenDisplay(0);', 1): + print "sorry, no headers or libs for X11 found, cant build alock." + Exit(1) +conf.Finish() + if alock_env['debug']: alock_env.AppendUnique( CPPDEFINES = [ 'DEBUG' ], @@ -90,7 +97,30 @@ if alock_env['xcursor']: print "sorry, no xcursor-support found." conf.Finish() +if alock_env['imlib2']: + conf = alock_env.Configure() + if not conf.env.WhereIs('imlib2-config'): + print "cant find 'imlib2-config. exit." + Exit(1) + imlib2_env = Environment() + imlib2_env.ParseConfig('imlib2-config --cflags --libs') + if not imlib2_env.Dictionary()['LIBS']: + print "missing imlib2, install it." + Exit(1) + + alock_env.AppendUnique( + CPPDEFINES = [ 'HAVE_IMLIB2' ], + LIBPATH = imlib2_env.Dictionary()['LIBPATH'], + CPPAPTH = imlib2_env.Dictionary()['CPPPATH'], + LIBS = imlib2_env.Dictionary()['LIBS'] + ) + + +############################################################################ +# +# + default_targets = [ alock_target ] if alock_env['amd5']: default_targets += [ 'src/amd5' ] diff --git a/alock.txt b/alock.txt index 4730c91..e543964 100644 --- a/alock.txt +++ b/alock.txt @@ -44,14 +44,18 @@ OPTIONS -bg type:options :: Define the type of alock should handle the background: - list - Displays a list of available types - - none - you can see everything like it is - - blank:color - fill the background with color + - none - You can see everything like it is + - blank:color - Fill the background with color + - image:name,center,scale,tile,color= - Use the image and puts it as + the background. -cursor type:options :: Define the look-a-like of the cursor/mouse pointer: - list - Displays a list of available types - - theme:name,bg=color,fg=color - - Use the given internal cursor + - theme:name,bg=,fg= - Use the given internal cursor, if name == "list" it lists + the available themes + - font:name,bg=,fg= - Use the given glyph of the "cursor"-font, if name == + "list" it lists the available glyphnames - xcursor:file - Use the given cursorfile in xcursor-format - none - no change to the current cursor diff --git a/src/SConscript b/src/SConscript index 1638412..a114c20 100644 --- a/src/SConscript +++ b/src/SConscript @@ -25,6 +25,8 @@ if build['pam']: if build['xcursor']: cursor_sources += [ 'cursor_xcursor.c' ] +if build['imlib2']: + bg_sources += [ 'bg_imlib2.c' ] alock_sources += auth_sources + bg_sources + cursor_sources diff --git a/src/alock.c b/src/alock.c index 87e9f32..ef58352 100644 --- a/src/alock.c +++ b/src/alock.c @@ -1,27 +1,15 @@ -/*------------------------------------------------------------------*\ - file: alock.c +/* ---------------------------------------------------------------- *\ - X Transparent Lock + file : alock.c + author : m. gumz + copyr : copyright (c) 2005 by m. gumz - copyright: + license : see LICENSE + + start : Sa 30 April 2005 14:19:44 CEST - Copyright (C)2005 Mathias Gumz (forked alock) - Copyright (C)1993,1994 Ian Jackson (xtrlock) - - license: - - This is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -\*------------------------------------------------------------------*/ +\* ---------------------------------------------------------------- */ /*------------------------------------------------------------------*\ \*------------------------------------------------------------------*/ @@ -30,10 +18,6 @@ #include #include #include - -#ifdef HAVE_XPM -# include -#endif /* HAVE_XPM */ #include #include #include @@ -46,18 +30,6 @@ /*------------------------------------------------------------------*\ globals \*------------------------------------------------------------------*/ - -#define TIMEOUTPERATTEMPT 30000 -#define MAXGOODWILL (TIMEOUTPERATTEMPT*5) -#define INITIALGOODWILL MAXGOODWILL -#define GOODWILLPORTION 0.3 - -#ifdef DEBUG -# define DBGMSG fprintf(stderr, "%s : %d\n", __FUNCTION__, __LINE__); fflush(stderr) -#else -# define DBGMSG -#endif // DEBUG - static struct aAuth* alock_authmodules[] = { #ifdef PAM_PWD &alock_auth_pam, @@ -76,6 +48,9 @@ static struct aAuth* alock_authmodules[] = { static struct aBackground* alock_backgrounds[] = { &alock_bg_none, &alock_bg_blank, +#ifdef HAVE_IMLIB2 + &alock_bg_imlib2, +#endif /* HAVE_IMLIB2 */ NULL }; @@ -88,7 +63,6 @@ static struct aCursor* alock_cursors[] = { #endif /* HAVE_XCURSOR */ NULL }; - /*------------------------------------------------------------------*\ \*------------------------------------------------------------------*/ @@ -114,32 +88,81 @@ void initXInfo(struct aXInfo* xinfo, struct aOpts* opts) { xinfo->root = DefaultRootWindow(dpy); xinfo->colormap = DefaultColormap(dpy, DefaultScreen(dpy)); - - /* TODO: doesnt work yet. */ -/* - * if (opts->cursor_name && (strstr(opts->cursor_name, "xbm:"))) { - unsigned int w, h, xhot, yhot; - if (XReadBitmapFile(dpy, xinfo->root, &opts->cursor_name[4], - &w, &h, &pixmap_cursor, &xhot, &yhot)) { - xinfo->cursor = XCreatePixmapCursor(dpy, - pixmap_cursor, NULL, - &color_fg, &color_bg, - xhot, yhot); - return; - } else { - printf("alock: error, couldnt load [%s]\n", &opts->cursor_name[4]); - } - } - */ } -int main(int argc, char **argv) { - +int event_loop(struct aOpts* opts, struct aXInfo* xinfo) { + XEvent ev; KeySym ks; char cbuf[10], rbuf[50]; int clen, rlen = 0; - long goodwill = INITIALGOODWILL, timeout = 0; + + long goodwill = 5 * 30000; + long timeout = 0; + + for(;;) { + XNextEvent(xinfo->display, &ev); + switch (ev.type) { + case KeyPress: + + if (ev.xkey.time < timeout) { + XBell(xinfo->display, 0); + break; + } + + clen = XLookupString(&ev.xkey, cbuf, 9, &ks, 0); + switch (ks) { + case XK_Escape: + case XK_Clear: + rlen = 0; + break; + case XK_Delete: + case XK_BackSpace: + if (rlen > 0) + rlen--; + break; + case XK_Linefeed: + case XK_Return: + if (rlen == 0) + break; + if (rlen < sizeof(rbuf)) + rbuf[rlen] = 0; + + if (opts->auth->auth(rbuf)) + return 1; + + XSync(xinfo->display, True); /* discard pending events to start really fresh */ + XBell(xinfo->display, 0); + rlen = 0; + if (timeout) { + goodwill += ev.xkey.time - timeout; + if (goodwill > 5 * 30000) { + goodwill = 5 * 30000; + } + } + timeout = -goodwill * 0.3; + goodwill += timeout; + timeout += ev.xkey.time + 30000; + break; + default: + if (clen != 1) + break; + if (rlen < sizeof(rbuf)) + rbuf[rlen] = cbuf[0]; + rlen++; + break; + } + break; + default: + break; + } + } + + return 0; +} + +int main(int argc, char **argv) { + struct aXInfo xinfo; struct aOpts opts; @@ -180,12 +203,12 @@ int main(int argc, char **argv) { } if (!bg_tmp) { - fprintf(stderr, "alock: error, couldnt find the bg-module you specified.\n"); + printf("alock: error, couldnt find the bg-module you specified.\n"); exit(1); } } else { - fprintf(stderr, "alock, error, missing argument\n"); + printf("alock, error, missing argument\n"); displayUsage(); exit(1); } @@ -207,7 +230,7 @@ int main(int argc, char **argv) { if(char_tmp && char_tmp == argv[arg]) { auth_tmp = (*i); if (!auth_tmp->init(argv[arg])) { - fprintf(stderr, "alock: error, failed init of [%s].\n", auth_tmp->name); + printf("alock: error, failed init of [%s].\n", auth_tmp->name); exit(1); } opts.auth = auth_tmp; @@ -217,12 +240,12 @@ int main(int argc, char **argv) { } if (!auth_tmp) { - fprintf(stderr, "alock: error, couldnt find the auth-module you specified.\n"); + printf("alock: error, couldnt find the auth-module you specified.\n"); exit(1); } } else { - fprintf(stderr, "alock, error, missing argument\n"); + printf("alock, error, missing argument\n"); displayUsage(); exit(1); } @@ -251,12 +274,12 @@ int main(int argc, char **argv) { } if (!cursor_tmp) { - fprintf(stderr, "alock: error, couldnt find the cursor-module you specified.\n"); + printf("alock: error, couldnt find the cursor-module you specified.\n"); exit(1); } } else { - fprintf(stderr, "alock, error, missing argument\n"); + printf("alock, error, missing argument\n"); displayUsage(); exit(1); } @@ -290,30 +313,6 @@ int main(int argc, char **argv) { XMapWindow(xinfo.display, xinfo.window); XRaiseWindow(xinfo.display, xinfo.window); - /* TODO: -bg */ - /* if (opts.use_blank) { - XImage* ximage; - - ximage = XGetImage (xinfo.display, xinfo.root, 0, 0, - xinfo.width, xinfo.height, AllPlanes, ZPixmap); - - if (ximage) { - GC gc; - XGCValues xgcv; - xgcv.background = BlackPixel(xinfo.display, DefaultScreen(xinfo.display)); - xgcv.foreground = 0; - - gc = XCreateGC(xinfo.display, xinfo.window, GCForeground|GCBackground, &xgcv); - - XPutImage(xinfo.display, xinfo.window, - gc, - ximage, - 0, 0, - 0, 0, xinfo.width, xinfo.height); - XDestroyImage(ximage); - XFreeGC(xinfo.display, gc); - } - } */ /* try to grab 2 times, another process (windowmanager) may have grabbed * the keyboard already */ if ((XGrabKeyboard(xinfo.display, xinfo.window, True, GrabModeAsync, GrabModeAsync, @@ -321,7 +320,7 @@ int main(int argc, char **argv) { sleep(1); if ((XGrabKeyboard(xinfo.display, xinfo.window, True, GrabModeAsync, GrabModeAsync, CurrentTime)) != GrabSuccess) { - perror("alock: couldnt grab the keyboard.\n"); + printf("alock: couldnt grab the keyboard.\n"); exit(1); } } @@ -329,69 +328,11 @@ int main(int argc, char **argv) { if (XGrabPointer(xinfo.display, xinfo.window, False, (KeyPressMask|KeyReleaseMask) & 0, GrabModeAsync, GrabModeAsync, None, xinfo.cursor, CurrentTime) != GrabSuccess) { XUngrabKeyboard(xinfo.display, CurrentTime); - perror("alock: couldnt grab the pointer.\n"); + printf("alock: couldnt grab the pointer.\n"); exit(1); } - /* eventhandling */ - for(;;) { - XNextEvent(xinfo.display, &ev); - switch (ev.type) { - case KeyPress: - - if (ev.xkey.time < timeout) { - XBell(xinfo.display, 0); - break; - } - - clen = XLookupString(&ev.xkey, cbuf, 9, &ks, 0); - switch (ks) { - case XK_Escape: - case XK_Clear: - rlen = 0; - break; - case XK_Delete: - case XK_BackSpace: - if (rlen > 0) - rlen--; - break; - case XK_Linefeed: - case XK_Return: - if (rlen == 0) - break; - rbuf[rlen] = 0; - - if (opts.auth->auth(rbuf)) - goto exit; - - XSync(xinfo.display, True); /* discard pending events to start really fresh */ - XBell(xinfo.display, 0); - rlen = 0; - if (timeout) { - goodwill += ev.xkey.time - timeout; - if (goodwill > MAXGOODWILL) { - goodwill = MAXGOODWILL; - } - } - timeout = -goodwill * GOODWILLPORTION; - goodwill += timeout; - timeout += ev.xkey.time + TIMEOUTPERATTEMPT; - break; - default: - if (clen != 1) - break; - if (rlen < sizeof(rbuf)) - rbuf[rlen] = cbuf[0]; - rlen++; - break; - } - break; - default: - break; - } - } - -exit: + event_loop(&opts, &xinfo); opts.auth->deinit(); opts.cursor->deinit(&xinfo); diff --git a/src/alock.h b/src/alock.h index 1c6daac..be5b93a 100644 --- a/src/alock.h +++ b/src/alock.h @@ -21,8 +21,13 @@ /* ---------------------------------------------------------------- *\ \* ---------------------------------------------------------------- */ - - +#ifdef DEBUG +# define DBGMSG fprintf(stderr, "%s : %d\n", __FUNCTION__, __LINE__); fflush(stderr) +#else +# define DBGMSG +#endif // DEBUG +/*------------------------------------------------------------------*\ +\*------------------------------------------------------------------*/ struct aXInfo { @@ -64,6 +69,9 @@ struct aOpts { \*------------------------------------------------------------------*/ extern struct aBackground alock_bg_none; extern struct aBackground alock_bg_blank; +#ifdef HAVE_IMLIB2 +extern struct aBackground alock_bg_imlib2; +#endif /* HAVE_IMLIB2 */ /*------------------------------------------------------------------*\ \*------------------------------------------------------------------*/ extern struct aAuth alock_auth_none; diff --git a/src/bg_blank.c b/src/bg_blank.c index dfbab7d..b21aaec 100644 --- a/src/bg_blank.c +++ b/src/bg_blank.c @@ -21,31 +21,55 @@ includes \* ---------------------------------------------------------------- */ #include +#include +#include +#include #include "alock.h" /* ---------------------------------------------------------------- *\ \* ---------------------------------------------------------------- */ static Window window = 0; +static XColor color; static int alock_bg_blank_init(const char* args, struct aXInfo* xinfo) { XWindowAttributes xgwa; XSetWindowAttributes xswa; long xsmask = 0; + XColor tmp_color; + char* color_name = strdup("black"); - if (!xinfo) + if (!xinfo || !args) return 0; - /* TODO: parse args for color */ + if (strstr(args, "blank:") == args && strlen(&args[6]) > 0) { + char* arguments = strdup(&args[6]); + char* tmp; + char* arg = NULL; + for (tmp = arguments; tmp; ) { + arg = strsep(&tmp, ","); + if (arg) { + if (strstr(arg, "color=") == arg && strlen(arg) > 6 && strlen(&arg[6])) { + free(color_name); + color_name = strdup(&arg[6]); + } + } + } + free(arguments); + } + + if((XAllocNamedColor(xinfo->display, xinfo->colormap, color_name, &tmp_color, &color)) == 0) + XAllocNamedColor(xinfo->display, xinfo->colormap, "black", &tmp_color, &color); + + free(color_name); XGetWindowAttributes(xinfo->display, xinfo->root, &xgwa); xswa.override_redirect = True; xswa.colormap = xinfo->colormap; - xswa.background_pixel = BlackPixel(xinfo->display, - DefaultScreen(xinfo->display)); - + xswa.background_pixel = color.pixel; + xsmask |= CWOverrideRedirect; xsmask |= CWBackPixel; xsmask |= CWColormap; @@ -58,6 +82,7 @@ static int alock_bg_blank_init(const char* args, struct aXInfo* xinfo) { CopyFromParent, /* visual */ xsmask, &xswa); + if (window) xinfo->window = window; diff --git a/src/bg_imlib2.c b/src/bg_imlib2.c new file mode 100644 index 0000000..c89ba30 --- /dev/null +++ b/src/bg_imlib2.c @@ -0,0 +1,212 @@ +/* ---------------------------------------------------------------- *\ + + file : bg_imlib2.c + author : m. gumz + copyr : copyright (c) 2005 by m. gumz + + license : see LICENSE + + start : Mi 18 Mai 2005 00:51:10 CEST + +\* ---------------------------------------------------------------- */ +/* ---------------------------------------------------------------- *\ + + about : + + provide -bg image:filename via imlib2 + +\* ---------------------------------------------------------------- */ + +/* ---------------------------------------------------------------- *\ + includes +\* ---------------------------------------------------------------- */ +#include +#include +#include +#include +#include +#include "alock.h" + + +/* ---------------------------------------------------------------- *\ +\* ---------------------------------------------------------------- */ + +enum { + ALOCK_SCALE = 1, + ALOCK_CENTER = 2, + ALOCK_TILED = 4 +}; + +static Window window = 0; +static Pixmap pixmap = 0; +static XColor color; + +static int alock_bg_imlib2_init(const char* args, struct aXInfo* xinfo) { + + XWindowAttributes xgwa; + XSetWindowAttributes xswa; + long xsmask = 0; + long options = ALOCK_SCALE; + XColor tmp_color; + char* filename = NULL; + char* color_name = strdup("black"); + + if (!xinfo || !args) + return 0; + + if (strstr(args, "image:") == args && strlen(&args[6]) > 0) { + char* arguments = strdup(&args[6]); + char* tmp; + char* arg = NULL; + for (tmp = arguments; tmp; ) { + arg = strsep(&tmp, ","); + if (arg) { + if (strstr(arg, "scale") == arg) { + options = ALOCK_SCALE; + } else if (strstr(arg, "center")) { + options = ALOCK_CENTER; + } else if (strstr(arg, "tile")) { + options = ALOCK_TILED; + } else if (strstr(arg, "color=") == arg && strlen(arg) > 6 && strlen(&arg[6])) { + free(color_name); + color_name = strdup(&arg[6]); + } else { + if (!filename) + filename = strdup(arg); + } + } + } + free(arguments); + } + + if (!filename) { + printf("alock: error, no filename specified for [image]\n"); + return 1; + } + + if((XAllocNamedColor(xinfo->display, xinfo->colormap, color_name, &tmp_color, &color)) == 0) + XAllocNamedColor(xinfo->display, xinfo->colormap, "black", &tmp_color, &color); + + free(color_name); + + XGetWindowAttributes(xinfo->display, xinfo->root, &xgwa); + + + /* get image and set it as the background pixmap for the window */ + { + Imlib_Context context = NULL; + Imlib_Image image = NULL; + + context = imlib_context_new(); + imlib_context_push(context); + imlib_context_set_display(xinfo->display); + imlib_context_set_visual(DefaultVisual(xinfo->display, + DefaultScreen(xinfo->display))); + imlib_context_set_colormap(xinfo->colormap); + + image = imlib_load_image_without_cache(filename); + if (image) { + + pixmap = XCreatePixmap(xinfo->display, xinfo->root, + xgwa.width, xgwa.height, + DefaultDepth(xinfo->display, DefaultScreen(xinfo->display))); + + imlib_context_set_image(image); + + if (options & ALOCK_CENTER) { + GC gc; + XGCValues gcval; + int w = imlib_image_get_width(); + int h = imlib_image_get_height(); + + gcval.foreground = color.pixel; + gc = XCreateGC(xinfo->display, xinfo->root, GCForeground, &gcval); + XFillRectangle(xinfo->display, pixmap, gc, 0, 0, xgwa.width, xgwa.height); + imlib_context_set_drawable(pixmap); + imlib_render_image_on_drawable((xgwa.width - w)/2, (xgwa.height - h)/2); + XFreeGC(xinfo->display, gc); + } else if (options & ALOCK_TILED) { + Pixmap tile; + GC gc; + XGCValues gcval; + int w = imlib_image_get_width(); + int h = imlib_image_get_height(); + + tile = XCreatePixmap(xinfo->display, xinfo->root, + w, h, DefaultDepth(xinfo->display, DefaultScreen(xinfo->display))); + + imlib_context_set_drawable(tile); + imlib_render_image_on_drawable(0, 0); + + gcval.fill_style = FillTiled; + gcval.tile = tile; + gc = XCreateGC(xinfo->display, tile, GCFillStyle|GCTile, &gcval); + XFillRectangle(xinfo->display, pixmap, gc, 0, 0, xgwa.width, xgwa.height); + + XFreeGC(xinfo->display, gc); + XFreePixmap(xinfo->display, tile); + } else {/* fallback is ALOCK_SCALE */ + imlib_context_set_drawable(pixmap); + imlib_render_image_on_drawable_at_size(0, 0, xgwa.width, xgwa.height); + } + imlib_free_image_and_decache(); + + } else { + printf("alock: error, couldnt load [%s].\n", filename); + if (filename) + free(filename); + XDestroyWindow(xinfo->display, window); + return 0; + } + + imlib_context_pop(); + imlib_context_free(context); + context = NULL; + } + + xswa.override_redirect = True; + xswa.colormap = xinfo->colormap; + xswa.background_pixmap = pixmap; + + xsmask |= CWOverrideRedirect; + xsmask |= CWColormap; + xsmask |= CWBackPixmap; + + window = XCreateWindow(xinfo->display, xinfo->root, + 0, 0, xgwa.width, xgwa.height, + 0, /* borderwidth */ + CopyFromParent, /* depth */ + InputOutput, /* class */ + CopyFromParent, /* visual */ + xsmask, &xswa); + + XMapWindow(xinfo->display, window); + + if (window) + xinfo->window = window; + + if (filename) + free(filename); + + return window; +} + + +static int alock_bg_imlib2_deinit(struct aXInfo* xinfo) { + if (!xinfo || !window) + return 0; + XDestroyWindow(xinfo->display, window); + XFreePixmap(xinfo->display, pixmap); + return 1; +} + +struct aBackground alock_bg_imlib2 = { + "image", + alock_bg_imlib2_init, + alock_bg_imlib2_deinit +}; + +/* ---------------------------------------------------------------- *\ +\* ---------------------------------------------------------------- */ + + diff --git a/src/cursor_font.c b/src/cursor_font.c index 780fc97..75474d8 100644 --- a/src/cursor_font.c +++ b/src/cursor_font.c @@ -153,11 +153,11 @@ static int alock_cursor_font_init(const char* args, struct aXInfo* xinfo) { free(arguments); exit(0); } - if (strstr(arg, "fg=") == arg && strlen(&arg[3])) { + if (strstr(arg, "fg=") == arg && strlen(arg) > 3 && strlen(&arg[3])) { free(color_fg_name); color_fg_name = strdup(&arg[3]); } - else if (strstr(arg, "bg=") == arg && strlen(&arg[3])) { + else if (strstr(arg, "bg=") == arg && strlen(arg) > 3 && strlen(&arg[3])) { free(color_bg_name); color_bg_name = strdup(&arg[3]); } diff --git a/src/cursor_theme.c b/src/cursor_theme.c index e779be1..e776efe 100644 --- a/src/cursor_theme.c +++ b/src/cursor_theme.c @@ -104,11 +104,11 @@ static int alock_cursor_theme_init(const char* args, struct aXInfo* xinfo) { free(arguments); exit(0); } - if (strstr(arg, "fg=") == arg && strlen(&arg[3])) { + if (strstr(arg, "fg=") == arg && strlen(arg) > 3 && strlen(&arg[3])) { free(color_fg_name); color_fg_name = strdup(&arg[3]); } - else if (strstr(arg, "bg=") == arg && strlen(&arg[3])) { + else if (strstr(arg, "bg=") == arg && strlen(arg) > 3 && strlen(&arg[3])) { free(color_bg_name); color_bg_name = strdup(&arg[3]); } diff --git a/src/cursor_xcursor.c b/src/cursor_xcursor.c index 2aa1a63..f202b5b 100644 --- a/src/cursor_xcursor.c +++ b/src/cursor_xcursor.c @@ -22,6 +22,7 @@ \* ---------------------------------------------------------------- */ #include #include +#include #include "alock.h" /* ---------------------------------------------------------------- *\ @@ -34,13 +35,13 @@ static int alock_cursor_xcursor_init(const char* args, struct aXInfo* xinfo) { if (!xinfo) return 0; - if (!args) { + if (!args || strlen(args) < 8) { printf("alock: error, missing arguments for [xcursor]\n"); return 0; } - if (!(cursor = XcursorFilenameLoadCursor(xinfo->display, args))) { - printf("alock: error, couldnt load [%s]\n", args); + if (!(cursor = XcursorFilenameLoadCursor(xinfo->display, &args[8]))) { + printf("alock: error, couldnt load [%s]\n", &args[8]); return 0; }