diff --git a/config.c b/config.c index 62d972b..931cd86 100644 --- a/config.c +++ b/config.c @@ -154,14 +154,14 @@ init_conf(void) static cfg_opt_t colors_opts[] = { - CFG_INT("border_normal", 0x354B5C, CFGF_NONE), - CFG_INT("border_focus", 0x6286A1, CFGF_NONE), - CFG_INT("bar", 0x090909, CFGF_NONE), - CFG_INT("text", 0x6289A1, CFGF_NONE), - CFG_INT("tag_sel_fg", 0xFFFFFF, CFGF_NONE), - CFG_INT("tag_sel_bg", 0x354B5C, CFGF_NONE), - CFG_INT("layout_fg", 0xFFFFFF, CFGF_NONE), - CFG_INT("layout_bg", 0x292929, CFGF_NONE), + CFG_STR("border_normal", "#354B5C", CFGF_NONE), + CFG_STR("border_focus", "#6286A1", CFGF_NONE), + CFG_STR("bar", "#090909", CFGF_NONE), + CFG_STR("text", "#6289A1", CFGF_NONE), + CFG_STR("tag_sel_fg", "#FFFFFF", CFGF_NONE), + CFG_STR("tag_sel_bg", "#354B5C", CFGF_NONE), + CFG_STR("layout_fg", "#FFFFFF", CFGF_NONE), + CFG_STR("layout_bg", "#292929", CFGF_NONE), CFG_END() }; @@ -220,8 +220,8 @@ init_conf(void) { CFG_STR("text", "", CFGF_NONE), CFG_SEC("mouse", mouse_button_opts, CFGF_MULTI), - CFG_INT("fg_color", 0x000000, CFGF_NONE), - CFG_INT("bg_color", 0xFFFFFF, CFGF_NONE), + CFG_STR("fg_color", "#000000", CFGF_NONE), + CFG_STR("bg_color", "#FFFFFF", CFGF_NONE), CFG_INT("x", 0, CFGF_NONE), CFG_END() }; @@ -269,7 +269,7 @@ init_conf(void) sprintf(sfinal_path, "%s/wmfs/wmfsrc", XDG_CONFIG_DIR); printf("WMFS: parsing configuration file (%s) failed\n" "Use the default configuration (%s).\n", final_path, sfinal_path); - ret = cfg_parse(cfg, sfinal_path); + ret = cfg_parse(cfg, sfinal_path); } cfg_misc = cfg_getsec(cfg, "misc"); @@ -293,19 +293,19 @@ init_conf(void) conf.font.size = cfg_getint(cfg_font, "size"); /* colors */ - conf.colors.bordernormal = cfg_getint(cfg_colors, "border_normal"); - conf.colors.borderfocus = cfg_getint(cfg_colors, "border_focus"); - conf.colors.bar = cfg_getint(cfg_colors, "bar"); - conf.colors.text = cfg_getint(cfg_colors, "text"); - conf.colors.tagselfg = cfg_getint(cfg_colors, "tag_sel_fg"); - conf.colors.tagselbg = cfg_getint(cfg_colors, "tag_sel_bg"); - conf.colors.layout_fg = cfg_getint(cfg_colors, "layout_fg"); - conf.colors.layout_bg = cfg_getint(cfg_colors, "layout_bg"); + conf.colors.bordernormal = getcolor(strdup(cfg_getstr(cfg_colors, "border_normal"))); + conf.colors.borderfocus = getcolor(strdup(cfg_getstr(cfg_colors, "border_focus"))); + conf.colors.bar = getcolor(strdup(cfg_getstr(cfg_colors, "bar"))); + conf.colors.text = getcolor(strdup(cfg_getstr(cfg_colors, "text"))); + conf.colors.tagselfg = getcolor(strdup(cfg_getstr(cfg_colors, "tag_sel_fg"))); + conf.colors.tagselbg = getcolor(strdup(cfg_getstr(cfg_colors, "tag_sel_bg"))); + conf.colors.layout_fg = getcolor(strdup(cfg_getstr(cfg_colors, "layout_fg"))); + conf.colors.layout_bg = getcolor(strdup(cfg_getstr(cfg_colors, "layout_bg"))); /* layout */ conf.nlayout = cfg_size(cfg_layouts, "layout"); - if(conf.nlayout > 3) + if(conf.nlayout > ) { printf("WMFS Configuration: Too much of layouts\n"); exit(EXIT_FAILURE); @@ -395,8 +395,8 @@ init_conf(void) } conf.barbutton[i].nmousesec = cfg_size(cfgtmp2, "mouse"); conf.barbutton[i].text = strdup(cfg_getstr(cfgtmp2, "text")); - conf.barbutton[i].fg_color = cfg_getint(cfgtmp2, "fg_color"); - conf.barbutton[i].bg_color = cfg_getint(cfgtmp2, "bg_color"); + conf.barbutton[i].fg_color = getcolor(strdup(cfg_getstr(cfgtmp2, "fg_color"))); + conf.barbutton[i].bg_color = getcolor(strdup(cfg_getstr(cfgtmp2, "bg_color"))); conf.barbutton[i].x = cfg_getint(cfgtmp2, "x"); } diff --git a/util.c b/util.c index 16d0e06..2142458 100644 --- a/util.c +++ b/util.c @@ -43,6 +43,17 @@ emalloc(unsigned int element, unsigned int size) return ret; } +unsigned long +getcolor(char *color) +{ + Colormap cmap = DefaultColormap(dpy, screen); + XColor xcolor; + + if(!XAllocNamedColor(dpy, cmap, color, &xcolor, &xcolor)) + fprintf(stderr,"WMFS Error: cannot allocate color \"%s\"\n", color); + return xcolor.pixel; +} + void uicb_spawn(char *cmd) { diff --git a/wmfs.h b/wmfs.h index 76a516e..fbd3b9d 100644 --- a/wmfs.h +++ b/wmfs.h @@ -209,6 +209,7 @@ void getevent(void); /* util.c */ void *emalloc(unsigned int elemet, unsigned int size); +unsigned long getcolor(char *color); void uicb_spawn(char *cmd); /* tag.c */ diff --git a/wmfsrc b/wmfsrc index 86713da..c2569e6 100644 --- a/wmfsrc +++ b/wmfsrc @@ -18,14 +18,14 @@ font colors { - border_normal = 0x3F485E - border_focus = 0x7E89A2 - bar = 0x191919 - text = 0xD4D4D4 - tag_sel_fg = 0x000000 - tag_sel_bg = 0x7E89A2 - layout_fg = 0x000000 - layout_bg = 0x7E89A2 + border_normal = "#3F485E" + border_focus = "#7E89A2" + bar = "#191919" + text = "#D4D4D4" + tag_sel_fg = "#000000" + tag_sel_bg = "#7E89A2" + layout_fg = "#000000" + layout_bg = "#7E89A2" } layouts @@ -55,12 +55,12 @@ buttons { text = "[-]" mouse { button = "Button1" func = "set_mwfact" cmd = "-0.01"} - fg_color = 0xFFFFFF - bg_color = 0x191919 + fg_color = "#FFFFFF" + bg_color = "#191919" } button { - text = "Mwfact" fg_color = 0xFFFFFF bg_color = 0x3E3E3E + text = "Mwfact" fg_color = "#FFFFFF" bg_color = "#3E3E3E" mouse { button = "Button4" func = "set_mwfact" cmd = "+0.01"} mouse { button = "Button5" func = "set_mwfact" cmd = "-0.01"} } @@ -68,8 +68,8 @@ buttons { text = "[+] " mouse { button = "Button1" func = "set_mwfact" cmd = "+0.01"} - fg_color = 0xFFFFFF - bg_color = 0x191919 + fg_color = "#FFFFFF" + bg_color = "#191919" } # }}} @@ -78,16 +78,16 @@ buttons { text = "[-]" mouse { button = "Button1" func = "set_nmaster" cmd = "-1"} - fg_color = 0xFFFFFF - bg_color = 0x191919 + fg_color = "#FFFFFF" + bg_color = "#191919" } - button { text = "Nmaster" fg_color = 0xFFFFFF bg_color = 0x3E3E3E } + button { text = "Nmaster" fg_color = "#FFFFFF" bg_color = "#3E3E3E" } button { text = "[+] " mouse { button = "Button1" func = "set_nmaster" cmd = "+1"} - fg_color = 0xFFFFFF - bg_color = 0x191919 + fg_color = "#FFFFFF" + bg_color = "#191919" } # }}} }