* 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 * added -cursor none, doesnt change cursor --HG-- extra : convert_revision : svn%3Aeebe1cee-a9af-4fe4-bd26-ad572b19c5ab/trunk%4013
This commit is contained in:
parent
9caf7ba1f2
commit
6ac8241d2a
16 changed files with 869 additions and 250 deletions
10
CHANGELOG
10
CHANGELOG
|
@ -1,4 +1,12 @@
|
|||
Version 0.5
|
||||
Version 0.9
|
||||
2005-05-17:
|
||||
|
||||
* 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
|
||||
* added -cursor none, doesnt change cursor
|
||||
|
||||
2005-05-16:
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import sys
|
||||
|
||||
alock_version = '0.5'
|
||||
alock_version = '0.9'
|
||||
alock_optfile = [ 'scons.opts', 'user.opts' ]
|
||||
|
||||
alock_target = 'src/alock'
|
||||
|
|
|
@ -5,19 +5,28 @@
|
|||
#
|
||||
##########################################################
|
||||
|
||||
alock_sources = [ 'alock.c', 'cursors.c', 'auth_none.c' ]
|
||||
alock_sources = [ 'alock.c' ]
|
||||
|
||||
auth_sources = [ 'auth_none.c' ]
|
||||
bg_sources = [ 'bg_none.c', 'bg_blank.c' ]
|
||||
cursor_sources = [ 'cursor_none.c', 'cursor_theme.c', 'cursor_font.c' ]
|
||||
|
||||
Import('alock_env')
|
||||
|
||||
build = alock_env.Copy()
|
||||
|
||||
if build['passwd']:
|
||||
alock_sources += [ 'auth_passwd.c' ]
|
||||
auth_sources += [ 'auth_passwd.c' ]
|
||||
if build['hash']:
|
||||
alock_sources += [ 'auth_md5.c', 'auth_sha1.c' ]
|
||||
auth_sources += [ 'auth_md5.c', 'auth_sha1.c' ]
|
||||
if build['pam']:
|
||||
alock_sources += [ 'auth_pam.c' ]
|
||||
auth_sources += [ 'auth_pam.c' ]
|
||||
|
||||
if build['xcursor']:
|
||||
cursor_sources += [ 'cursor_xcursor.c' ]
|
||||
|
||||
|
||||
alock_sources += auth_sources + bg_sources + cursor_sources
|
||||
|
||||
alock = build.Program('alock', alock_sources)
|
||||
build.AddPostAction(alock, Chmod(alock, 0755))
|
||||
|
|
246
src/alock.c
246
src/alock.c
|
@ -30,15 +30,10 @@
|
|||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/Xos.h>
|
||||
#include <X11/cursorfont.h>
|
||||
|
||||
#ifdef HAVE_XPM
|
||||
# include <X11/xpm.h>
|
||||
#endif /* HAVE_XPM */
|
||||
#ifdef HAVE_XCURSOR
|
||||
# include <X11/Xcursor/Xcursor.h>
|
||||
#endif /* HAVE_XCURSOR */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -48,18 +43,6 @@
|
|||
|
||||
#include "alock.h"
|
||||
|
||||
struct aXInfo {
|
||||
|
||||
Display* display;
|
||||
Window root;
|
||||
Window window;
|
||||
Colormap colormap;
|
||||
|
||||
Cursor cursor;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
/*------------------------------------------------------------------*\
|
||||
globals
|
||||
\*------------------------------------------------------------------*/
|
||||
|
@ -90,51 +73,36 @@ static struct aAuth* alock_authmodules[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
static struct aBackground* alock_backgrounds[] = {
|
||||
&alock_bg_none,
|
||||
&alock_bg_blank,
|
||||
NULL
|
||||
};
|
||||
|
||||
static struct aCursor* alock_cursors[] = {
|
||||
&alock_cursor_theme,
|
||||
&alock_cursor_none,
|
||||
&alock_cursor_font,
|
||||
#ifdef HAVE_XCURSOR
|
||||
&alock_cursor_xcursor,
|
||||
#endif /* HAVE_XCURSOR */
|
||||
NULL
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
\*------------------------------------------------------------------*/
|
||||
|
||||
void displayUsage() {
|
||||
printf("\n");
|
||||
printf("alock [-h] [-v] [-blank] [-cursor <theme|xcursor:file>]\n");
|
||||
printf(" [-auth list|<none");
|
||||
#ifdef PASSWD_PWD
|
||||
printf("|passwd");
|
||||
#endif /* PASSWD_PWD */
|
||||
#ifdef PAM_PWD
|
||||
printf("|pam");
|
||||
#endif /* PAM_PWD */
|
||||
#ifdef HASH_PWD
|
||||
printf("|md5:pwdhash|sha1:pwdhash");
|
||||
#endif /* HASH_PWD */
|
||||
printf(">]\n");
|
||||
printf("alock [-hv] [-bg type:options] [-cursor type:options] ");
|
||||
printf("[-auth type:options]\n");
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
\*------------------------------------------------------------------*/
|
||||
|
||||
void initOpts(struct aOpts* opts) {
|
||||
|
||||
opts->auth = alock_authmodules[0];
|
||||
opts->use_blank = 0;
|
||||
|
||||
opts->cursor_name = "mini";
|
||||
|
||||
opts->color_bg = "steelblue3";
|
||||
opts->color_fg = "grey25";
|
||||
|
||||
}
|
||||
|
||||
void initXInfo(struct aXInfo* xinfo, struct aOpts* opts) {
|
||||
|
||||
|
||||
Display* dpy = XOpenDisplay(NULL);
|
||||
XColor color_fg;
|
||||
XColor color_bg;
|
||||
XColor tmp_color;
|
||||
Pixmap pixmap_cursor;
|
||||
Pixmap pixmap_cursor_mask;
|
||||
XWindowAttributes xgwa;
|
||||
struct aCursor* cursor = NULL;
|
||||
|
||||
if (!dpy) {
|
||||
perror("alock: error, can't open connection to X");
|
||||
|
@ -146,45 +114,7 @@ void initXInfo(struct aXInfo* xinfo, struct aOpts* opts) {
|
|||
|
||||
xinfo->root = DefaultRootWindow(dpy);
|
||||
xinfo->colormap = DefaultColormap(dpy, DefaultScreen(dpy));
|
||||
|
||||
XGetWindowAttributes(dpy, xinfo->root, &xgwa);
|
||||
|
||||
if (opts->use_blank) {
|
||||
xinfo->width = xgwa.width;
|
||||
xinfo->height = xgwa.height;
|
||||
} else {
|
||||
xinfo->width = 1;
|
||||
xinfo->height = 1;
|
||||
}
|
||||
|
||||
if((XAllocNamedColor(dpy, xinfo->colormap, opts->color_bg, &tmp_color, &color_bg)) == 0)
|
||||
XAllocNamedColor(dpy, xinfo->colormap, "black", &tmp_color, &color_bg);
|
||||
if((XAllocNamedColor(dpy, xinfo->colormap, opts->color_fg, &tmp_color, &color_fg)) == 0)
|
||||
XAllocNamedColor(dpy, xinfo->colormap, "white", &tmp_color, &color_fg);
|
||||
|
||||
/* load cursors */
|
||||
#ifdef HAVE_XCURSOR
|
||||
if (opts->cursor_name && (strstr(opts->cursor_name, "xcursor:"))) {
|
||||
Cursor xcursor;
|
||||
if ((xcursor = XcursorFilenameLoadCursor(dpy, &opts->cursor_name[8]))) {
|
||||
xinfo->cursor = xcursor;
|
||||
return;
|
||||
} else {
|
||||
printf("alock: error, couldnt load [%s]\n", &opts->cursor_name[8]);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_XCURSOR */
|
||||
/* create cursor from X11/cursorfont.h */
|
||||
if (opts->cursor_name && (strstr(opts->cursor_name, "font:"))) {
|
||||
Cursor fcursor;
|
||||
if ((fcursor = XCreateFontCursor(dpy, atoi(&opts->cursor_name[5])))) {
|
||||
XRecolorCursor(dpy, fcursor, &color_fg, &color_bg);
|
||||
xinfo->cursor = fcursor;
|
||||
return;
|
||||
} else
|
||||
printf("alock: error, couldnt creat fontcursor [%d].\n", atoi(&opts->cursor_name[5]));
|
||||
|
||||
}
|
||||
|
||||
/* TODO: doesnt work yet. */
|
||||
/*
|
||||
* if (opts->cursor_name && (strstr(opts->cursor_name, "xbm:"))) {
|
||||
|
@ -201,24 +131,6 @@ void initXInfo(struct aXInfo* xinfo, struct aOpts* opts) {
|
|||
}
|
||||
}
|
||||
*/
|
||||
/* look internal cursors */
|
||||
for(cursor = alock_cursors; cursor->name != NULL; cursor++) {
|
||||
if (!strcmp(cursor->name, opts->cursor_name))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!cursor->name)
|
||||
cursor = alock_cursors;
|
||||
|
||||
pixmap_cursor = XCreateBitmapFromData(dpy, xinfo->root, cursor->bits, cursor->width, cursor->height);
|
||||
pixmap_cursor_mask = XCreateBitmapFromData(dpy, xinfo->root, cursor->mask, cursor->width, cursor->height);
|
||||
|
||||
xinfo->cursor = XCreatePixmapCursor(dpy,
|
||||
pixmap_cursor, pixmap_cursor_mask,
|
||||
&color_fg, &color_bg,
|
||||
cursor->x_hot, cursor->y_hot);
|
||||
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
@ -229,21 +141,54 @@ int main(int argc, char **argv) {
|
|||
int clen, rlen = 0;
|
||||
long goodwill = INITIALGOODWILL, timeout = 0;
|
||||
|
||||
XSetWindowAttributes xswa;
|
||||
long xsmask = 0;
|
||||
|
||||
struct aXInfo xinfo;
|
||||
struct aOpts opts;
|
||||
|
||||
int arg = 0;
|
||||
const char* cursor_args = NULL;
|
||||
const char* background_args = NULL;
|
||||
|
||||
initOpts(&opts);
|
||||
opts.auth = alock_authmodules[0];
|
||||
opts.cursor = alock_cursors[0];
|
||||
opts.background = alock_backgrounds[0];
|
||||
|
||||
/* parse options */
|
||||
if (argc != 1) {
|
||||
for(arg = 1; arg <= argc; arg++) {
|
||||
if (!strcmp(argv[arg - 1], "-blank")) {
|
||||
opts.use_blank = 1;
|
||||
if (!strcmp(argv[arg - 1], "-bg")) {
|
||||
if (arg < argc) {
|
||||
|
||||
char* char_tmp;
|
||||
struct aBackground* bg_tmp = NULL;
|
||||
struct aBackground** i;
|
||||
if (!strcmp(argv[arg], "list")) {
|
||||
for(i = alock_backgrounds; *i; ++i) {
|
||||
printf("%s\n", (*i)->name);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for(i = alock_backgrounds; *i; ++i) {
|
||||
char_tmp = strstr(argv[arg], (*i)->name);
|
||||
if(char_tmp && char_tmp == argv[arg]) {
|
||||
background_args = char_tmp;
|
||||
bg_tmp = *i;
|
||||
opts.background = bg_tmp;
|
||||
++arg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bg_tmp) {
|
||||
fprintf(stderr, "alock: error, couldnt find the bg-module you specified.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
} else {
|
||||
fprintf(stderr, "alock, error, missing argument\n");
|
||||
displayUsage();
|
||||
exit(1);
|
||||
}
|
||||
} else if (!strcmp(argv[arg - 1], "-auth")) {
|
||||
if (arg < argc) {
|
||||
|
||||
|
@ -272,7 +217,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (!auth_tmp) {
|
||||
fprintf(stderr, "alock: error, couldnt find the auth module you specified.\n");
|
||||
fprintf(stderr, "alock: error, couldnt find the auth-module you specified.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -282,10 +227,36 @@ int main(int argc, char **argv) {
|
|||
exit(1);
|
||||
}
|
||||
} else if (!strcmp(argv[arg - 1], "-cursor")) {
|
||||
if (arg < argc)
|
||||
opts.cursor_name = argv[arg];
|
||||
else {
|
||||
printf("alock: error, missing argument\n");
|
||||
if (arg < argc) {
|
||||
|
||||
char* char_tmp;
|
||||
struct aCursor* cursor_tmp = NULL;
|
||||
struct aCursor** i;
|
||||
if (!strcmp(argv[arg], "list")) {
|
||||
for(i = alock_cursors; *i; ++i) {
|
||||
printf("%s\n", (*i)->name);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for(i = alock_cursors; *i; ++i) {
|
||||
char_tmp = strstr(argv[arg], (*i)->name);
|
||||
if(char_tmp && char_tmp == argv[arg]) {
|
||||
cursor_args = char_tmp;
|
||||
cursor_tmp = *i;
|
||||
opts.cursor= cursor_tmp;
|
||||
++arg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cursor_tmp) {
|
||||
fprintf(stderr, "alock: error, couldnt find the cursor-module you specified.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
} else {
|
||||
fprintf(stderr, "alock, error, missing argument\n");
|
||||
displayUsage();
|
||||
exit(1);
|
||||
}
|
||||
|
@ -301,27 +272,19 @@ int main(int argc, char **argv) {
|
|||
|
||||
initXInfo(&xinfo, &opts);
|
||||
|
||||
/* create the windows */
|
||||
xswa.override_redirect = True;
|
||||
xsmask |= CWOverrideRedirect;
|
||||
|
||||
if (opts.use_blank) {
|
||||
|
||||
xswa.background_pixel = BlackPixel(xinfo.display, DefaultScreen(xinfo.display));
|
||||
xswa.colormap = xinfo.colormap;
|
||||
xsmask |= CWBackPixel;
|
||||
xsmask |= CWColormap;
|
||||
if (!opts.background->init(background_args, &xinfo)) {
|
||||
printf("alock: error, couldnt init [%s] with [%s].\n",
|
||||
opts.background->name,
|
||||
background_args);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
xinfo.window = XCreateWindow(xinfo.display, xinfo.root,
|
||||
0, 0, xinfo.width, xinfo.height,
|
||||
0, /* borderwidth */
|
||||
CopyFromParent, /* depth */
|
||||
InputOutput, /* class */
|
||||
CopyFromParent, /* visual */
|
||||
xsmask, &xswa);
|
||||
|
||||
|
||||
if (!opts.cursor->init(cursor_args, &xinfo)) {
|
||||
printf("alock: error, couldnt init [%s] with [%s].\n",
|
||||
opts.cursor->name,
|
||||
cursor_args);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XSelectInput(xinfo.display, xinfo.window, KeyPressMask|KeyReleaseMask);
|
||||
XMapWindow(xinfo.display, xinfo.window);
|
||||
|
@ -424,18 +387,17 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
|
||||
opts.auth->deinit();
|
||||
|
||||
XDestroyWindow(xinfo.display, xinfo.window);
|
||||
XFreeCursor(xinfo.display, xinfo.cursor);
|
||||
opts.cursor->deinit(&xinfo);
|
||||
opts.background->deinit(&xinfo);
|
||||
XCloseDisplay(xinfo.display);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
49
src/alock.h
49
src/alock.h
|
@ -22,6 +22,18 @@
|
|||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
|
||||
|
||||
struct aXInfo {
|
||||
|
||||
Display* display;
|
||||
Window root;
|
||||
Colormap colormap;
|
||||
|
||||
Window window;
|
||||
Cursor cursor;
|
||||
};
|
||||
|
||||
struct aAuth {
|
||||
const char* name;
|
||||
int (*init)(const char* args);
|
||||
|
@ -31,34 +43,27 @@ struct aAuth {
|
|||
|
||||
struct aCursor {
|
||||
const char* name;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int x_hot;
|
||||
unsigned int y_hot;
|
||||
|
||||
unsigned char* bits;
|
||||
unsigned char* mask;
|
||||
int (*init)(const char* args, struct aXInfo* xinfo);
|
||||
int (*deinit)(struct aXInfo* xinfo);
|
||||
};
|
||||
|
||||
|
||||
struct aBackground {
|
||||
const char* name;
|
||||
int (*init)(const char* args, struct aXInfo* xinfo);
|
||||
int (*deinit)(struct aXInfo* xinfo);
|
||||
};
|
||||
|
||||
struct aOpts {
|
||||
|
||||
struct aAuth* auth;
|
||||
char use_blank;
|
||||
|
||||
char* cursor_name;
|
||||
|
||||
char* color_fg;
|
||||
char* color_bg;
|
||||
struct aCursor* cursor;
|
||||
struct aBackground* background;
|
||||
};
|
||||
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
\*------------------------------------------------------------------*/
|
||||
extern struct aCursor alock_cursors[];
|
||||
|
||||
|
||||
extern struct aBackground alock_bg_none;
|
||||
extern struct aBackground alock_bg_blank;
|
||||
/*------------------------------------------------------------------*\
|
||||
\*------------------------------------------------------------------*/
|
||||
extern struct aAuth alock_auth_none;
|
||||
|
@ -72,6 +77,14 @@ extern struct aAuth alock_auth_passwd;
|
|||
#ifdef PAM_PWD
|
||||
extern struct aAuth alock_auth_pam;
|
||||
#endif /* PAM_PWD */
|
||||
/*------------------------------------------------------------------*\
|
||||
\*------------------------------------------------------------------*/
|
||||
extern struct aCursor alock_cursor_none;
|
||||
extern struct aCursor alock_cursor_theme;
|
||||
extern struct aCursor alock_cursor_font;
|
||||
#ifdef HAVE_XCURSOR
|
||||
extern struct aCursor alock_cursor_xcursor;
|
||||
#endif /* HAVE_XCURSOR */
|
||||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
#endif // _ALOCK_H_
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
about :
|
||||
|
||||
provide -auth md5:hash
|
||||
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
|
@ -33,7 +35,8 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifndef STAND_ALONE
|
||||
#include "alock.h"
|
||||
# include <X11/Xlib.h>
|
||||
# include "alock.h"
|
||||
#endif /* STAND_ALONE */
|
||||
/*------------------------------------------------------------------*\
|
||||
\*------------------------------------------------------------------*/
|
||||
|
@ -52,11 +55,11 @@ typedef struct {
|
|||
u_int8_t buffer[MD5_BLOCK_LENGTH]; /* input buffer */
|
||||
} md5Context;
|
||||
|
||||
void md5_init(md5Context*);
|
||||
void md5_update(md5Context*, const u_int8_t*, size_t);
|
||||
void md5_pad(md5Context*);
|
||||
void md5_final(u_int8_t [MD5_DIGEST_LENGTH], md5Context*);
|
||||
void md5_transform(u_int32_t [4], const u_int8_t [MD5_BLOCK_LENGTH]);
|
||||
static void md5_init(md5Context*);
|
||||
static void md5_update(md5Context*, const u_int8_t*, size_t);
|
||||
static void md5_pad(md5Context*);
|
||||
static void md5_final(u_int8_t [MD5_DIGEST_LENGTH], md5Context*);
|
||||
static void md5_transform(u_int32_t [4], const u_int8_t [MD5_BLOCK_LENGTH]);
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
\*------------------------------------------------------------------*/
|
||||
|
@ -87,7 +90,7 @@ static u_int8_t PADDING[MD5_BLOCK_LENGTH] = {
|
|||
Start MD5 accumulation. Set bit count to 0 and buffer to
|
||||
mysterious initialization constants.
|
||||
\*------------------------------------------------------------------*/
|
||||
void md5_init(md5Context* ctx) {
|
||||
static void md5_init(md5Context* ctx) {
|
||||
ctx->count = 0;
|
||||
ctx->state[0] = 0x67452301;
|
||||
ctx->state[1] = 0xefcdab89;
|
||||
|
@ -98,7 +101,7 @@ void md5_init(md5Context* ctx) {
|
|||
Update context to reflect the concatenation of another buffer
|
||||
full of bytes.
|
||||
\*------------------------------------------------------------------*/
|
||||
void md5_update(md5Context* ctx, const unsigned char* input, size_t len) {
|
||||
static void md5_update(md5Context* ctx, const unsigned char* input, size_t len) {
|
||||
|
||||
size_t have, need;
|
||||
|
||||
|
@ -135,7 +138,7 @@ void md5_update(md5Context* ctx, const unsigned char* input, size_t len) {
|
|||
Pad pad to 64-byte boundary with the bit pattern
|
||||
1 0* (64-bit count of bits processed, MSB-first)
|
||||
\*------------------------------------------------------------------*/
|
||||
void md5_pad(md5Context *ctx)
|
||||
static void md5_pad(md5Context *ctx)
|
||||
{
|
||||
u_int8_t count[8];
|
||||
size_t padlen;
|
||||
|
@ -155,7 +158,7 @@ void md5_pad(md5Context *ctx)
|
|||
/*------------------------------------------------------------------*\
|
||||
Final wrapup--call MD5Pad, fill in digest and zero out ctx.
|
||||
\*------------------------------------------------------------------*/
|
||||
void md5_final(unsigned char digest[MD5_DIGEST_LENGTH], md5Context *ctx) {
|
||||
static void md5_final(unsigned char digest[MD5_DIGEST_LENGTH], md5Context *ctx) {
|
||||
int i;
|
||||
|
||||
md5_pad(ctx);
|
||||
|
@ -184,7 +187,7 @@ void md5_final(unsigned char digest[MD5_DIGEST_LENGTH], md5Context *ctx) {
|
|||
the data and converts bytes into longwords for this routine.
|
||||
|
||||
\*------------------------------------------------------------------*/
|
||||
void md5_transform(u_int32_t state[4], const u_int8_t block[MD5_BLOCK_LENGTH]) {
|
||||
static void md5_transform(u_int32_t state[4], const u_int8_t block[MD5_BLOCK_LENGTH]) {
|
||||
u_int32_t a, b, c, d, in[MD5_BLOCK_LENGTH / 4];
|
||||
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
|
@ -285,16 +288,16 @@ void md5_transform(u_int32_t state[4], const u_int8_t block[MD5_BLOCK_LENGTH]) {
|
|||
|
||||
static const char* userhash = NULL;
|
||||
|
||||
static int init(const char* args) {
|
||||
static int alock_auth_md5_init(const char* args) {
|
||||
if (args) {
|
||||
char* check = strstr(args, "md5:");
|
||||
if (!check || check != args) {
|
||||
fprintf(stderr, "aklock: error, missing arguments for [md5].\n");
|
||||
fprintf(stderr, "alock: error, missing arguments for [md5].\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strlen(&args[4]) != MD5_DIGEST_STRING_LENGTH - 1) {
|
||||
fprintf(stderr, "aklock: error, invalid md5-hash.\n");
|
||||
fprintf(stderr, "alock: error, invalid md5-hash.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -305,11 +308,11 @@ static int init(const char* args) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int deinit() {
|
||||
static int alock_auth_md5_deinit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int auth(const char* pass) {
|
||||
static int alock_auth_md5_auth(const char* pass) {
|
||||
|
||||
unsigned char digest[MD5_DIGEST_LENGTH];
|
||||
unsigned char stringdigest[MD5_DIGEST_STRING_LENGTH];
|
||||
|
@ -333,9 +336,9 @@ static int auth(const char* pass) {
|
|||
|
||||
struct aAuth alock_auth_md5 = {
|
||||
"md5",
|
||||
init,
|
||||
auth,
|
||||
deinit
|
||||
alock_auth_md5_init,
|
||||
alock_auth_md5_auth,
|
||||
alock_auth_md5_deinit
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
|
|
|
@ -11,35 +11,38 @@
|
|||
\* ---------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------- *\
|
||||
|
||||
about : this authmodule does absolutly nothing :)
|
||||
about :
|
||||
|
||||
provide -auth none, any "password" is accepted
|
||||
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
includes
|
||||
\* ---------------------------------------------------------------- */
|
||||
#include <X11/Xlib.h>
|
||||
#include "alock.h"
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
static int init(const char* args) {
|
||||
static int alock_auth_none_init(const char* args) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int deinit() {
|
||||
static int alock_auth_none_deinit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int auth(const char* passwd) {
|
||||
static int alock_auth_none_auth(const char* passwd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct aAuth alock_auth_none = {
|
||||
"none",
|
||||
init,
|
||||
deinit,
|
||||
auth
|
||||
alock_auth_none_init,
|
||||
alock_auth_none_deinit,
|
||||
alock_auth_none_auth
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
about :
|
||||
|
||||
pam-authentification for aklock
|
||||
provide -auth pam, pam-authentification for alock
|
||||
|
||||
taken from pure-ftpd's authstuff, but you can see similar stuff
|
||||
in xlockmore, openssh and basicly all pam-related apps :)
|
||||
|
@ -24,6 +24,7 @@
|
|||
includes
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
@ -127,7 +128,7 @@ static struct pam_conv PAM_conversation = {
|
|||
static struct passwd* pwd_entry = NULL;
|
||||
|
||||
|
||||
static int init(const char* args) {
|
||||
static int alock_auth_pam_init(const char* args) {
|
||||
errno = 0;
|
||||
pwd_entry = getpwuid(getuid());
|
||||
if (!pwd_entry) {
|
||||
|
@ -142,14 +143,14 @@ static int init(const char* args) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int deinit() {
|
||||
static int alock_auth_pam_deinit() {
|
||||
|
||||
pwd_entry = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int auth(const char* pass) {
|
||||
static int alock_auth_pam_auth(const char* pass) {
|
||||
|
||||
pam_handle_t* pam_handle = NULL;
|
||||
|
||||
|
@ -170,9 +171,9 @@ static int auth(const char* pass) {
|
|||
|
||||
struct aAuth alock_auth_pam = {
|
||||
"pam",
|
||||
init,
|
||||
auth,
|
||||
deinit
|
||||
alock_auth_pam_init,
|
||||
alock_auth_pam_auth,
|
||||
alock_auth_pam_deinit
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
|
|
|
@ -13,11 +13,15 @@
|
|||
|
||||
about :
|
||||
|
||||
provide -auth passwd, normal unix-login, either with or without
|
||||
shadowsupport
|
||||
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
includes
|
||||
\* ---------------------------------------------------------------- */
|
||||
#include <X11/Xlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -39,7 +43,7 @@
|
|||
|
||||
static struct passwd* pwd_entry = NULL;
|
||||
|
||||
static int init(const char* args) {
|
||||
static int alock_auth_passwd_init(const char* args) {
|
||||
|
||||
#ifdef SHADOW_PWD
|
||||
struct spwd* sp = NULL;
|
||||
|
@ -71,11 +75,11 @@ static int init(const char* args) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int deinit() {
|
||||
static int alock_auth_passwd_deinit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int auth(const char* pass) {
|
||||
static int alock_auth_passwd_auth(const char* pass) {
|
||||
#if 0
|
||||
char key[3];
|
||||
char *encr;
|
||||
|
@ -100,9 +104,9 @@ static int auth(const char* pass) {
|
|||
|
||||
struct aAuth aklock_auth_passwd = {
|
||||
"passwd",
|
||||
init,
|
||||
auth,
|
||||
deinit
|
||||
alock_auth_passwd_init,
|
||||
alock_auth_passwd_auth,
|
||||
alock_auth_passwd_deinit
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
about :
|
||||
|
||||
provide -auth sha1:hash
|
||||
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
|
@ -29,7 +31,8 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifndef STAND_ALONE
|
||||
#include "alock.h"
|
||||
# include <X11/Xlib.h>
|
||||
# include "alock.h"
|
||||
#endif /* STAND_ALONE */
|
||||
/*------------------------------------------------------------------*\
|
||||
\*------------------------------------------------------------------*/
|
||||
|
@ -47,11 +50,11 @@ typedef struct {
|
|||
} sha1Context;
|
||||
|
||||
|
||||
void sha1_init(sha1Context *);
|
||||
void sha1_pad(sha1Context *);
|
||||
void sha1_transform(u_int32_t [5], const u_int8_t [SHA1_BLOCK_LENGTH]);
|
||||
void sha1_update(sha1Context *, const u_int8_t *, size_t);
|
||||
void sha1_final(u_int8_t [SHA1_DIGEST_LENGTH], sha1Context *);
|
||||
static void sha1_init(sha1Context *);
|
||||
static void sha1_pad(sha1Context *);
|
||||
static void sha1_transform(u_int32_t [5], const u_int8_t [SHA1_BLOCK_LENGTH]);
|
||||
static void sha1_update(sha1Context *, const u_int8_t *, size_t);
|
||||
static void sha1_final(u_int8_t [SHA1_DIGEST_LENGTH], sha1Context *);
|
||||
|
||||
#define HTONDIGEST(x) do { \
|
||||
x[0] = htonl(x[0]); \
|
||||
|
@ -97,7 +100,7 @@ void sha1_final(u_int8_t [SHA1_DIGEST_LENGTH], sha1Context *);
|
|||
/*------------------------------------------------------------------*\
|
||||
Hash a single 512-bit block. This is the core of the algorithm.
|
||||
\*------------------------------------------------------------------*/
|
||||
void sha1_transform(u_int32_t state[5], const u_int8_t buffer[SHA1_BLOCK_LENGTH]) {
|
||||
static void sha1_transform(u_int32_t state[5], const u_int8_t buffer[SHA1_BLOCK_LENGTH]) {
|
||||
u_int32_t a, b, c, d, e;
|
||||
u_int8_t workspace[SHA1_BLOCK_LENGTH];
|
||||
typedef union {
|
||||
|
@ -151,7 +154,7 @@ void sha1_transform(u_int32_t state[5], const u_int8_t buffer[SHA1_BLOCK_LENGTH]
|
|||
/*------------------------------------------------------------------*\
|
||||
Initialize new context
|
||||
\*------------------------------------------------------------------*/
|
||||
void sha1_init(sha1Context *context) {
|
||||
static void sha1_init(sha1Context *context) {
|
||||
|
||||
/* SHA1 initialization constants */
|
||||
context->count = 0;
|
||||
|
@ -165,7 +168,7 @@ void sha1_init(sha1Context *context) {
|
|||
/*------------------------------------------------------------------*\
|
||||
Run your data through this.
|
||||
\*------------------------------------------------------------------*/
|
||||
void sha1_update(sha1Context *context, const u_int8_t *data, size_t len) {
|
||||
static void sha1_update(sha1Context *context, const u_int8_t *data, size_t len) {
|
||||
|
||||
size_t i, j;
|
||||
|
||||
|
@ -186,7 +189,7 @@ void sha1_update(sha1Context *context, const u_int8_t *data, size_t len) {
|
|||
/*------------------------------------------------------------------*\
|
||||
Add padding and return the message digest.
|
||||
\*------------------------------------------------------------------*/
|
||||
void sha1_pad(sha1Context *context) {
|
||||
static void sha1_pad(sha1Context *context) {
|
||||
|
||||
u_int8_t finalcount[8];
|
||||
u_int i;
|
||||
|
@ -201,7 +204,7 @@ void sha1_pad(sha1Context *context) {
|
|||
sha1_update(context, finalcount, 8); /* rsShould cause a sha1_transform() */
|
||||
}
|
||||
|
||||
void sha1_final(u_int8_t digest[SHA1_DIGEST_LENGTH], sha1Context *context) {
|
||||
static void sha1_final(u_int8_t digest[SHA1_DIGEST_LENGTH], sha1Context *context) {
|
||||
|
||||
u_int i;
|
||||
|
||||
|
@ -221,16 +224,16 @@ void sha1_final(u_int8_t digest[SHA1_DIGEST_LENGTH], sha1Context *context) {
|
|||
|
||||
static const char* userhash = NULL;
|
||||
|
||||
static int init(const char* args) {
|
||||
static int alock_auth_sha1_init(const char* args) {
|
||||
if (args) {
|
||||
char* check = strstr(args, "sha1:");
|
||||
if (!check || check != args) {
|
||||
fprintf(stderr, "aklock: error, missing arguments for [sha1].\n");
|
||||
fprintf(stderr, "alock: error, missing arguments for [sha1].\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strlen(&args[5]) != SHA1_DIGEST_STRING_LENGTH - 1) {
|
||||
fprintf(stderr, "aklock: error, invalid sha1-hash.\n");
|
||||
fprintf(stderr, "alock: error, invalid sha1-hash.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -241,11 +244,11 @@ static int init(const char* args) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int deinit() {
|
||||
static int alock_auth_sha1_deinit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int auth(const char* pass) {
|
||||
static int alock_auth_sha1_auth(const char* pass) {
|
||||
|
||||
unsigned char digest[SHA1_DIGEST_LENGTH];
|
||||
unsigned char stringdigest[SHA1_DIGEST_STRING_LENGTH];
|
||||
|
@ -269,9 +272,9 @@ static int auth(const char* pass) {
|
|||
|
||||
struct aAuth alock_auth_sha1 = {
|
||||
"sha1",
|
||||
init,
|
||||
auth,
|
||||
deinit
|
||||
alock_auth_sha1_init,
|
||||
alock_auth_sha1_auth,
|
||||
alock_auth_sha1_deinit
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
|
|
82
src/bg_blank.c
Normal file
82
src/bg_blank.c
Normal file
|
@ -0,0 +1,82 @@
|
|||
/* ---------------------------------------------------------------- *\
|
||||
|
||||
file : bg_blank.c
|
||||
author : m. gumz <akira at fluxbox dot org>
|
||||
copyr : copyright (c) 2005 by m. gumz
|
||||
|
||||
license : see LICENSE
|
||||
|
||||
start : Di 17 Mai 2005 10:44:20 CEST
|
||||
|
||||
\* ---------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------- *\
|
||||
|
||||
about :
|
||||
|
||||
provides -bg blank:color
|
||||
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
includes
|
||||
\* ---------------------------------------------------------------- */
|
||||
#include <X11/Xlib.h>
|
||||
#include "alock.h"
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
static Window window = 0;
|
||||
|
||||
static int alock_bg_blank_init(const char* args, struct aXInfo* xinfo) {
|
||||
|
||||
XWindowAttributes xgwa;
|
||||
XSetWindowAttributes xswa;
|
||||
long xsmask = 0;
|
||||
|
||||
if (!xinfo)
|
||||
return 0;
|
||||
|
||||
/* TODO: parse args for color */
|
||||
|
||||
XGetWindowAttributes(xinfo->display, xinfo->root, &xgwa);
|
||||
|
||||
xswa.override_redirect = True;
|
||||
xswa.colormap = xinfo->colormap;
|
||||
xswa.background_pixel = BlackPixel(xinfo->display,
|
||||
DefaultScreen(xinfo->display));
|
||||
|
||||
xsmask |= CWOverrideRedirect;
|
||||
xsmask |= CWBackPixel;
|
||||
xsmask |= CWColormap;
|
||||
|
||||
window = XCreateWindow(xinfo->display, xinfo->root,
|
||||
0, 0, xgwa.width, xgwa.height,
|
||||
0, /* borderwidth */
|
||||
CopyFromParent, /* depth */
|
||||
InputOutput, /* class */
|
||||
CopyFromParent, /* visual */
|
||||
xsmask, &xswa);
|
||||
|
||||
if (window)
|
||||
xinfo->window = window;
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
static int alock_bg_blank_deinit(struct aXInfo* xinfo) {
|
||||
if (!xinfo || !window)
|
||||
return 0;
|
||||
XDestroyWindow(xinfo->display, window);
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct aBackground alock_bg_blank = {
|
||||
"blank",
|
||||
alock_bg_blank_init,
|
||||
alock_bg_blank_deinit
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
68
src/bg_none.c
Normal file
68
src/bg_none.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* ---------------------------------------------------------------- *\
|
||||
|
||||
file : bg_none.c
|
||||
author : m. gumz <akira at fluxbox dot org>
|
||||
copyr : copyright (c) 2005 by m. gumz
|
||||
|
||||
license : see LICENSE
|
||||
|
||||
start : Sa 14 Mai 2005 14:27:48 CEST
|
||||
|
||||
\* ---------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------- *\
|
||||
|
||||
about :
|
||||
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
includes
|
||||
\* ---------------------------------------------------------------- */
|
||||
#include <X11/Xlib.h>
|
||||
#include "alock.h"
|
||||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
static Window window = 0;
|
||||
|
||||
static int alock_bg_none_init(const char* args, struct aXInfo* xinfo) {
|
||||
|
||||
XSetWindowAttributes xswa;
|
||||
long xsmask = 0;
|
||||
|
||||
if (!xinfo)
|
||||
return 0;
|
||||
|
||||
xswa.override_redirect = True;
|
||||
xsmask |= CWOverrideRedirect;
|
||||
|
||||
window = XCreateWindow(xinfo->display, xinfo->root,
|
||||
0, 0, 1, 1,
|
||||
0, /* borderwidth */
|
||||
CopyFromParent, /* depth */
|
||||
InputOnly, /* class */
|
||||
CopyFromParent, /* visual */
|
||||
xsmask, &xswa);
|
||||
|
||||
if (window)
|
||||
xinfo->window = window;
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
static int alock_bg_none_deinit(struct aXInfo* xinfo) {
|
||||
if (!xinfo || !window)
|
||||
return 0;
|
||||
XDestroyWindow(xinfo->display, window);
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct aBackground alock_bg_none = {
|
||||
"none",
|
||||
alock_bg_none_init,
|
||||
alock_bg_none_deinit
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
226
src/cursor_font.c
Normal file
226
src/cursor_font.c
Normal file
|
@ -0,0 +1,226 @@
|
|||
/* ---------------------------------------------------------------- *\
|
||||
|
||||
file : cursor_font.c
|
||||
author : m. gumz <akira at fluxbox dot org>
|
||||
copyr : copyright (c) 2005 by m. gumz
|
||||
|
||||
license : see LICENSE
|
||||
|
||||
start : Di 17 Mai 2005 14:19:44 CEST
|
||||
|
||||
\* ---------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------- *\
|
||||
|
||||
about :
|
||||
|
||||
provide -cursor font:name
|
||||
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
includes
|
||||
\* ---------------------------------------------------------------- */
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/cursorfont.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "alock.h"
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
struct CursorFontName {
|
||||
const char* name;
|
||||
unsigned int shape;
|
||||
};
|
||||
|
||||
static const struct CursorFontName cursor_names[] = {
|
||||
{ "num_glyphs", XC_num_glyphs },
|
||||
{ "X_cursor", XC_X_cursor },
|
||||
{ "arrow", XC_arrow },
|
||||
{ "based_arrow_down", XC_based_arrow_down },
|
||||
{ "based_arrow_up", XC_based_arrow_up },
|
||||
{ "boat", XC_boat },
|
||||
{ "bogosity", XC_bogosity },
|
||||
{ "bottom_left_corner", XC_bottom_left_corner },
|
||||
{ "bottom_right_corner", XC_bottom_right_corner },
|
||||
{ "bottom_side", XC_bottom_side },
|
||||
{ "bottom_tee", XC_bottom_tee },
|
||||
{ "box_spiral", XC_box_spiral },
|
||||
{ "center_ptr", XC_center_ptr },
|
||||
{ "circle", XC_circle },
|
||||
{ "clock", XC_clock },
|
||||
{ "coffee_mug", XC_coffee_mug },
|
||||
{ "cross", XC_cross },
|
||||
{ "cross_reverse", XC_cross_reverse },
|
||||
{ "crosshair", XC_crosshair },
|
||||
{ "diamond_cross", XC_diamond_cross },
|
||||
{ "dot", XC_dot },
|
||||
{ "dotbox", XC_dotbox },
|
||||
{ "double_arrow", XC_double_arrow },
|
||||
{ "draft_large", XC_draft_large },
|
||||
{ "draft_small", XC_draft_small },
|
||||
{ "draped_box", XC_draped_box },
|
||||
{ "exchange", XC_exchange },
|
||||
{ "fleur", XC_fleur },
|
||||
{ "gobbler", XC_gobbler },
|
||||
{ "gumby", XC_gumby },
|
||||
{ "hand1", XC_hand1 },
|
||||
{ "hand2", XC_hand2 },
|
||||
{ "heart", XC_heart },
|
||||
{ "icon", XC_icon },
|
||||
{ "iron_cross", XC_iron_cross },
|
||||
{ "left_ptr", XC_left_ptr },
|
||||
{ "left_side", XC_left_side },
|
||||
{ "left_tee", XC_left_tee },
|
||||
{ "leftbutton", XC_leftbutton },
|
||||
{ "ll_angle", XC_ll_angle },
|
||||
{ "lr_angle", XC_lr_angle },
|
||||
{ "man", XC_man },
|
||||
{ "middlebutton", XC_middlebutton },
|
||||
{ "mouse", XC_mouse },
|
||||
{ "pencil", XC_pencil },
|
||||
{ "pirate", XC_pirate },
|
||||
{ "plus", XC_plus },
|
||||
{ "question_arrow", XC_question_arrow },
|
||||
{ "right_ptr", XC_right_ptr },
|
||||
{ "right_side", XC_right_side },
|
||||
{ "right_tee", XC_right_tee },
|
||||
{ "rightbutton", XC_rightbutton },
|
||||
{ "rtl_logo", XC_rtl_logo },
|
||||
{ "sailboat", XC_sailboat },
|
||||
{ "sb_down_arrow", XC_sb_down_arrow },
|
||||
{ "sb_h_double_arrow", XC_sb_h_double_arrow },
|
||||
{ "sb_left_arrow", XC_sb_left_arrow },
|
||||
{ "sb_right_arrow", XC_sb_right_arrow },
|
||||
{ "sb_up_arrow", XC_sb_up_arrow },
|
||||
{ "sb_v_double_arrow", XC_sb_v_double_arrow },
|
||||
{ "shuttle", XC_shuttle },
|
||||
{ "sizing", XC_sizing },
|
||||
{ "spider", XC_spider },
|
||||
{ "spraycan", XC_spraycan },
|
||||
{ "star", XC_star },
|
||||
{ "target", XC_target },
|
||||
{ "tcross", XC_tcross },
|
||||
{ "top_left_arrow", XC_top_left_arrow },
|
||||
{ "top_left_corner", XC_top_left_corner },
|
||||
{ "top_right_corner", XC_top_right_corner },
|
||||
{ "top_side", XC_top_side },
|
||||
{ "top_tee", XC_top_tee },
|
||||
{ "trek", XC_trek },
|
||||
{ "ul_angle", XC_ul_angle },
|
||||
{ "umbrella", XC_umbrella },
|
||||
{ "ur_angle", XC_ur_angle },
|
||||
{ "watch", XC_watch },
|
||||
{ "xterm", XC_xterm },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
|
||||
\*------------------------------------------------------------------*/
|
||||
|
||||
static Cursor cursor = 0;
|
||||
static XColor color_fg;
|
||||
static XColor color_bg;
|
||||
|
||||
static int alock_cursor_font_init(const char* args, struct aXInfo* xinfo) {
|
||||
|
||||
XColor tmp_color;
|
||||
char* color_bg_name = strdup("steelblue3");
|
||||
char* color_fg_name = strdup("grey25");
|
||||
unsigned int shape = 0; /* XC_X_cursor */
|
||||
|
||||
if (!xinfo || !args)
|
||||
return 0;
|
||||
|
||||
if (strstr(args, "font:") == args && strlen(&args[5]) > 0) {
|
||||
char* arguments = strdup(&args[5]);
|
||||
char* tmp;
|
||||
char* arg = NULL;
|
||||
for (tmp = arguments; tmp; ) {
|
||||
arg = strsep(&tmp, ",");
|
||||
if (arg) {
|
||||
const struct CursorFontName* cursor_font_name;
|
||||
|
||||
if (!strcmp(arg, "list")) {
|
||||
for (cursor_font_name = cursor_names; cursor_font_name->name; ++cursor_font_name) {
|
||||
printf("%s\n", cursor_font_name->name);
|
||||
}
|
||||
free(color_fg_name);
|
||||
free(color_bg_name);
|
||||
free(arguments);
|
||||
exit(0);
|
||||
}
|
||||
if (strstr(arg, "fg=") == arg && strlen(&arg[3])) {
|
||||
free(color_fg_name);
|
||||
color_fg_name = strdup(&arg[3]);
|
||||
}
|
||||
else if (strstr(arg, "bg=") == arg && strlen(&arg[3])) {
|
||||
free(color_bg_name);
|
||||
color_bg_name = strdup(&arg[3]);
|
||||
}
|
||||
else {
|
||||
/* TODO: accept <int> as well -> strtol */
|
||||
for (cursor_font_name = cursor_names; cursor_font_name->name; ++cursor_font_name) {
|
||||
if(!strcmp(cursor_font_name->name, arg)) {
|
||||
shape = cursor_font_name->shape;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!cursor_font_name->name) {
|
||||
printf("alock: error, couldnt find [%s]\n", arg);
|
||||
free(color_bg_name);
|
||||
free(color_fg_name);
|
||||
free(arguments);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
free(arguments);
|
||||
}
|
||||
|
||||
if((XAllocNamedColor(xinfo->display, xinfo->colormap, color_bg_name, &tmp_color, &color_bg)) == 0)
|
||||
XAllocNamedColor(xinfo->display, xinfo->colormap, "black", &tmp_color, &color_bg);
|
||||
if((XAllocNamedColor(xinfo->display, xinfo->colormap, color_fg_name, &tmp_color, &color_fg)) == 0)
|
||||
XAllocNamedColor(xinfo->display, xinfo->colormap, "white", &tmp_color, &color_fg);
|
||||
|
||||
free(color_fg_name);
|
||||
free(color_bg_name);
|
||||
|
||||
/* create cursor from X11/cursorfont.h */
|
||||
if ((cursor = XCreateFontCursor(xinfo->display, shape))) {
|
||||
XRecolorCursor(xinfo->display, cursor, &color_fg, &color_bg);
|
||||
xinfo->cursor = cursor;
|
||||
} else {
|
||||
printf("alock: error, couldnt create fontcursor [%d].\n", shape);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int alock_cursor_font_deinit(struct aXInfo* xinfo) {
|
||||
|
||||
if (!xinfo || !cursor)
|
||||
return 0;
|
||||
|
||||
XFreeCursor(xinfo->display, cursor);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
struct aCursor alock_cursor_font = {
|
||||
"font",
|
||||
alock_cursor_font_init,
|
||||
alock_cursor_font_deinit
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
|
@ -1,18 +1,20 @@
|
|||
/* ---------------------------------------------------------------- *\
|
||||
|
||||
file : akcursors.c
|
||||
file : cursor_none.c
|
||||
author : m. gumz <akira at fluxbox dot org>
|
||||
copyr : copyright (c) 2005 by m. gumz
|
||||
|
||||
license : see LICENSE
|
||||
|
||||
start : Sa 30 Apr 2005 12:02:47 CEST
|
||||
start : Di 17 Mai 2005 12:10:35 CEST
|
||||
|
||||
\* ---------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------- *\
|
||||
|
||||
about :
|
||||
|
||||
provide -cursor none
|
||||
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
|
@ -24,34 +26,24 @@
|
|||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
#include <X11/bitmaps/xlogo16>
|
||||
static int alock_cursor_none_init(const char* args, struct aXInfo* xinfo) {
|
||||
xinfo->cursor = None;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int alock_cursor_none_deinit(struct aXInfo* xinfo) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct aCursor alock_cursor_none = {
|
||||
"none",
|
||||
alock_cursor_none_init,
|
||||
alock_cursor_none_deinit
|
||||
};
|
||||
|
||||
#include "../bitmaps/mini.bitmap"
|
||||
#include "../bitmaps/mini_mask.bitmap"
|
||||
|
||||
#include "../bitmaps/xtr.bitmap"
|
||||
#include "../bitmaps/xtr_mask.bitmap"
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
struct aCursor alock_cursors[] = {
|
||||
|
||||
{ "mini",
|
||||
mini_width, mini_height, mini_x_hot, mini_y_hot,
|
||||
mini_bits, mini_mask_bits },
|
||||
|
||||
{ "xtr",
|
||||
xtr_width, xtr_height, xtr_x_hot, xtr_y_hot,
|
||||
xtr_bits, xtr_mask_bits },
|
||||
|
||||
{ "xlogo16",
|
||||
xlogo16_width, xlogo16_height, xlogo16_width / 2, xlogo16_height / 2,
|
||||
xlogo16_bits, xlogo16_bits },
|
||||
|
||||
{ NULL, 0, 0, 0, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
\*------------------------------------------------------------------*/
|
||||
|
176
src/cursor_theme.c
Normal file
176
src/cursor_theme.c
Normal file
|
@ -0,0 +1,176 @@
|
|||
/* ---------------------------------------------------------------- *\
|
||||
|
||||
file : cursor_theme.c
|
||||
author : m. gumz <akira at fluxbox dot org>
|
||||
copyr : copyright (c) 2005 by m. gumz
|
||||
|
||||
license : see LICENSE
|
||||
|
||||
start : Sa 30 Apr 2005 12:02:47 CEST
|
||||
|
||||
\* ---------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------- *\
|
||||
|
||||
about :
|
||||
|
||||
provide -cursor theme:name,bg=color,fg=color
|
||||
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
includes
|
||||
\* ---------------------------------------------------------------- */
|
||||
#include <X11/Xlib.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "alock.h"
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
#include <X11/bitmaps/xlogo16>
|
||||
|
||||
#include "../bitmaps/mini.bitmap"
|
||||
#include "../bitmaps/mini_mask.bitmap"
|
||||
|
||||
#include "../bitmaps/xtr.bitmap"
|
||||
#include "../bitmaps/xtr_mask.bitmap"
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
struct ThemeCursor {
|
||||
const char* name;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int x_hot;
|
||||
unsigned int y_hot;
|
||||
char* bits;
|
||||
char* mask;
|
||||
};
|
||||
|
||||
static struct ThemeCursor cursors[] = {
|
||||
|
||||
{ "mini",
|
||||
mini_width, mini_height, mini_x_hot, mini_y_hot,
|
||||
mini_bits, mini_mask_bits },
|
||||
|
||||
{ "xtr",
|
||||
xtr_width, xtr_height, xtr_x_hot, xtr_y_hot,
|
||||
xtr_bits, xtr_mask_bits },
|
||||
|
||||
{ "xlogo16",
|
||||
xlogo16_width, xlogo16_height, xlogo16_width / 2, xlogo16_height / 2,
|
||||
xlogo16_bits, xlogo16_bits },
|
||||
|
||||
{ NULL, 0, 0, 0, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
\*------------------------------------------------------------------*/
|
||||
|
||||
static Cursor cursor = 0;
|
||||
static XColor color_fg;
|
||||
static XColor color_bg;
|
||||
static int alock_cursor_theme_init(const char* args, struct aXInfo* xinfo) {
|
||||
|
||||
char* color_bg_name = strdup("steelblue3");
|
||||
char* color_fg_name = strdup("grey25");
|
||||
XColor tmp_color;
|
||||
Pixmap pixmap_cursor;
|
||||
Pixmap pixmap_cursor_mask;
|
||||
const struct ThemeCursor* theme = cursors;
|
||||
|
||||
if (!xinfo || !args)
|
||||
return 0;
|
||||
|
||||
if (strstr(args, "theme:") == args && strlen(&args[6]) > 0) {
|
||||
char* arguments = strdup(&args[6]);
|
||||
char* tmp;
|
||||
char* arg = NULL;
|
||||
for (tmp = arguments; tmp; ) {
|
||||
arg = strsep(&tmp, ",");
|
||||
if (arg) {
|
||||
const struct ThemeCursor* cursor_theme_name;
|
||||
|
||||
if (!strcmp(arg, "list")) {
|
||||
for (cursor_theme_name = cursors; cursor_theme_name->name; ++cursor_theme_name) {
|
||||
printf("%s\n", cursor_theme_name->name);
|
||||
}
|
||||
free(color_fg_name);
|
||||
free(color_bg_name);
|
||||
free(arguments);
|
||||
exit(0);
|
||||
}
|
||||
if (strstr(arg, "fg=") == arg && strlen(&arg[3])) {
|
||||
free(color_fg_name);
|
||||
color_fg_name = strdup(&arg[3]);
|
||||
}
|
||||
else if (strstr(arg, "bg=") == arg && strlen(&arg[3])) {
|
||||
free(color_bg_name);
|
||||
color_bg_name = strdup(&arg[3]);
|
||||
}
|
||||
else {
|
||||
for (cursor_theme_name = cursors; cursor_theme_name->name; ++cursor_theme_name) {
|
||||
if(!strcmp(cursor_theme_name->name, arg)) {
|
||||
theme = cursor_theme_name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!cursor_theme_name->name) {
|
||||
printf("alock: error, couldnt find [%s]\n", arg);
|
||||
free(color_bg_name);
|
||||
free(color_fg_name);
|
||||
free(arguments);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
free(arguments);
|
||||
}
|
||||
|
||||
if((XAllocNamedColor(xinfo->display, xinfo->colormap, color_bg_name, &tmp_color, &color_bg)) == 0)
|
||||
XAllocNamedColor(xinfo->display, xinfo->colormap, "black", &tmp_color, &color_bg);
|
||||
if((XAllocNamedColor(xinfo->display, xinfo->colormap, color_fg_name, &tmp_color, &color_fg)) == 0)
|
||||
XAllocNamedColor(xinfo->display, xinfo->colormap, "white", &tmp_color, &color_fg);
|
||||
|
||||
free(color_fg_name);
|
||||
free(color_bg_name);
|
||||
|
||||
pixmap_cursor = XCreateBitmapFromData(xinfo->display, xinfo->root,
|
||||
theme->bits, theme->width, theme->height);
|
||||
pixmap_cursor_mask = XCreateBitmapFromData(xinfo->display, xinfo->root,
|
||||
theme->mask, theme->width, theme->height);
|
||||
|
||||
cursor = XCreatePixmapCursor(xinfo->display,
|
||||
pixmap_cursor, pixmap_cursor_mask,
|
||||
&color_fg, &color_bg,
|
||||
theme->x_hot, theme->y_hot);
|
||||
|
||||
if (cursor) {
|
||||
xinfo->cursor = cursor;
|
||||
return 1;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int alock_cursor_theme_deinit(struct aXInfo* xinfo) {
|
||||
if (!xinfo || !cursor)
|
||||
return 0;
|
||||
|
||||
XFreeCursor(xinfo->display, cursor);
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct aCursor alock_cursor_theme = {
|
||||
"theme",
|
||||
alock_cursor_theme_init,
|
||||
alock_cursor_theme_deinit
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
\*------------------------------------------------------------------*/
|
||||
|
69
src/cursor_xcursor.c
Normal file
69
src/cursor_xcursor.c
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* ---------------------------------------------------------------- *\
|
||||
|
||||
file : cursor_xcursor.c
|
||||
author : m. gumz <akira at fluxbox dot org>
|
||||
copyr : copyright (c) 2005 by m. gumz
|
||||
|
||||
license : see LICENSE
|
||||
|
||||
start : Di 17 Mai 2005 12:14:36 CEST
|
||||
|
||||
\* ---------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------- *\
|
||||
|
||||
about :
|
||||
|
||||
provide -cursor xcursor:file
|
||||
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
includes
|
||||
\* ---------------------------------------------------------------- */
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
#include "alock.h"
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
||||
static Cursor cursor = 0;
|
||||
|
||||
static int alock_cursor_xcursor_init(const char* args, struct aXInfo* xinfo) {
|
||||
|
||||
if (!xinfo)
|
||||
return 0;
|
||||
|
||||
if (!args) {
|
||||
printf("alock: error, missing arguments for [xcursor]\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(cursor = XcursorFilenameLoadCursor(xinfo->display, args))) {
|
||||
printf("alock: error, couldnt load [%s]\n", args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
xinfo->cursor = cursor;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int alock_cursor_xcursor_deinit(struct aXInfo* xinfo) {
|
||||
if (!xinfo || !cursor)
|
||||
return 0;
|
||||
|
||||
XFreeCursor(xinfo->display, cursor);
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct aCursor alock_cursor_xcursor = {
|
||||
"xcursor",
|
||||
alock_cursor_xcursor_init,
|
||||
alock_cursor_xcursor_deinit
|
||||
};
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------- *\
|
||||
\* ---------------------------------------------------------------- */
|
||||
|
Reference in a new issue