forked from bakkeby/slock-flexipatch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,8 @@ | |
|
||
#if PAMAUTH_PATCH | ||
#include "pamauth.c" | ||
#endif | ||
|
||
#if XRESOURCES_PATCH | ||
#include "xresources.c" | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
/* Patches */ | ||
#if PAMAUTH_PATCH | ||
#include "pamauth.h" | ||
#endif | ||
|
||
#if XRESOURCES_PATCH | ||
#include "xresources.h" | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <math.h> | ||
|
||
int | ||
resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst) | ||
{ | ||
char **sdst = dst; | ||
int *idst = dst; | ||
float *fdst = dst; | ||
|
||
char fullname[256]; | ||
char fullclass[256]; | ||
char *type; | ||
XrmValue ret; | ||
|
||
snprintf(fullname, sizeof(fullname), "%s.%s", "slock", name); | ||
snprintf(fullclass, sizeof(fullclass), "%s.%s", "Slock", name); | ||
fullname[sizeof(fullname) - 1] = fullclass[sizeof(fullclass) - 1] = '\0'; | ||
|
||
XrmGetResource(db, fullname, fullclass, &type, &ret); | ||
if (ret.addr == NULL || strncmp("String", type, 64)) | ||
return 1; | ||
|
||
switch (rtype) { | ||
case STRING: | ||
*sdst = ret.addr; | ||
break; | ||
case INTEGER: | ||
*idst = strtoul(ret.addr, NULL, 10); | ||
break; | ||
case FLOAT: | ||
*fdst = strtof(ret.addr, NULL); | ||
break; | ||
} | ||
return 0; | ||
} | ||
|
||
void | ||
config_init(Display *dpy) | ||
{ | ||
char *resm; | ||
XrmDatabase db; | ||
ResourcePref *p; | ||
|
||
XrmInitialize(); | ||
resm = XResourceManagerString(dpy); | ||
if (!resm) | ||
return; | ||
|
||
db = XrmGetStringDatabase(resm); | ||
for (p = resources; p < resources + LEN(resources); p++) | ||
resource_load(db, p->name, p->type, p->dst); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <X11/Xresource.h> | ||
|
||
/* macros */ | ||
#define LEN(a) (sizeof(a) / sizeof(a)[0]) | ||
|
||
/* Xresources preferences */ | ||
enum resource_type { | ||
STRING = 0, | ||
INTEGER = 1, | ||
FLOAT = 2 | ||
}; | ||
|
||
typedef struct { | ||
char *name; | ||
enum resource_type type; | ||
void *dst; | ||
} ResourcePref; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters