From 859338fd83f10c4bda8f1bf067fe529146330431 Mon Sep 17 00:00:00 2001 From: Tamas TEVESZ Date: Thu, 1 Apr 2010 03:32:14 +0200 Subject: [PATCH] Spice up setstyle - convert to getopt - tidy xsendevent - modify hackPathInTexture() so that: - it properly figures where the style file is - if it's under the user's home directory, that part of the path is changed to `~' - this makes your wm configuration usable on systems with a network home, used on systems where home is /home, or /u, or /export/home, or whatever. XXX: there's a note WINGs/findfile.c:wexpandpath() stating that `too many functions handle a return value of NULL incorrectly'. this is so true. so if anyone is looking for a small project to sink their teeth in... --- util/setstyle.c | 229 ++++++++++++++++++++++++++---------------------- 1 file changed, 122 insertions(+), 107 deletions(-) diff --git a/util/setstyle.c b/util/setstyle.c index 36224f58..5eb9b14e 100644 --- a/util/setstyle.c +++ b/util/setstyle.c @@ -22,12 +22,20 @@ #define PROG_VERSION "setstyle (Window Maker) 0.6" -#include -#include +#ifdef __GLIBC__ +#define _GNU_SOURCE /* getopt_long */ +#endif + #include -#include + +#include +#include +#include +#include #include +#include #include + #include #include "../src/wconfig.h" @@ -97,6 +105,12 @@ static Bool isFontOption(char *option) return False; } +/* + * finds elements in `texture' that reference external files, + * prepends `prefix' to these files. `prefix' is a path component + * that qualifies the external references to be absolute, possibly + * pending further expansion + */ void hackPathInTexture(WMPropList * texture, char *prefix) { WMPropList *type; @@ -107,12 +121,14 @@ void hackPathInTexture(WMPropList * texture, char *prefix) t = WMGetFromPLString(type); if (t == NULL) return; - if (strcasecmp(t, "tpixmap") == 0 - || strcasecmp(t, "spixmap") == 0 - || strcasecmp(t, "mpixmap") == 0 - || strcasecmp(t, "cpixmap") == 0 - || strcasecmp(t, "tvgradient") == 0 - || strcasecmp(t, "thgradient") == 0 || strcasecmp(t, "tdgradient") == 0) { + + if (strcasecmp(t, "tpixmap") == 0 || + strcasecmp(t, "spixmap") == 0 || + strcasecmp(t, "mpixmap") == 0 || + strcasecmp(t, "cpixmap") == 0 || + strcasecmp(t, "tvgradient") == 0 || + strcasecmp(t, "thgradient") == 0 || + strcasecmp(t, "tdgradient") == 0) { WMPropList *file; char buffer[4018]; @@ -122,6 +138,7 @@ void hackPathInTexture(WMPropList * texture, char *prefix) /* replace path with full path */ WMDeleteFromPLArray(texture, 1); WMInsertInPLArray(texture, 1, WMCreatePLString(buffer)); + } else if (strcasecmp(t, "bitmap") == 0) { WMPropList *file; char buffer[4018]; @@ -334,16 +351,19 @@ void hackStyle(WMPropList * style) } } -void print_help() +void print_help(int print_usage, int exitval) { printf("Usage: %s [OPTIONS] FILE\n", __progname); - puts("Reads style/theme configuration from FILE and updates Window Maker."); - puts(""); - puts(" --no-fonts ignore font related options"); - puts(" --no-cursors ignore cursor related options"); - puts(" --ignore