infobar: Add option to set the borders around the tag buttons, the layout button and the infobar.

This commit is contained in:
Martin Duquesnoy 2009-01-18 03:25:10 +01:00
parent d789c6d0f2
commit 796c7988d6
7 changed files with 79 additions and 11 deletions

View File

@ -54,7 +54,7 @@ send_client_message(char* atom_name, long data_l[5])
void
spawn(char* arg)
{
char *sh;
char *sh;
if(!(sh = getenv("SHELL")))
sh = "/bin/sh";
@ -110,11 +110,53 @@ exec_uicb_function(char *func, char *cmd)
return;
}
void
tag_get_current(char **name, int *num)
{
Atom rt;
int rf;
unsigned long ir, il;
unsigned char *ret;
if(name && XGetWindowProperty(dpy, ROOT, ATOM("_WMFS_CURRENT_TAG"), 0L, 4096,
False, ATOM("UTF8_STRING"), &rt, &rf, &ir, &il, &ret) == Success)
*name = (char*)ret;
if(XGetWindowProperty(dpy, ROOT, ATOM("_NET_CURRENT_DESKTOP"), 0L, 4096,
False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success)
*num = *(int*)ret;
if(ret)
XFree(ret);
return;
}
void
tag_set(int tag)
{
long data[5];
int t;
char *n;
if(tag >= 0)
data[0] = tag;
send_client_message("_NET_CURRENT_DESKTOP", data);
usleep(100000); /* For tag_get_current */
tag_get_current(&n, &t);
printf("Your now on '%s' (tag %d).\n", n, t);
return;
}
void
manage_input(char *input)
{
char *p = input;
char *q1, *q2, *tmp, *aargs = NULL, *func = input;
char *p = input, *func = input;
char *q1, *q2, *tmp, *aargs = NULL;
char **args;
int i, v = 0;
@ -174,6 +216,13 @@ manage_input(char *input)
exec_uicb_function(args[0], args[1]);
}
}
else if(!strcmp(func, "tag_set"))
{
if(v > 0 || !args[0])
printf("Tag_set: tag_set(<tag_number>), Set the current tag.\n");
else
tag_set(atoi(args[0]));
}
else if(!strcmp(func, "statustext"))
{
if(v > 0 || !args[0])
@ -191,6 +240,8 @@ manage_input(char *input)
free(args);
}
else
printf("Unknow command '%s', try 'help'.\n", input);
return;
}
@ -198,7 +249,8 @@ manage_input(char *input)
int
main(void)
{
char *input, *p, c;
char *input, *p;
int c;
init();
@ -215,7 +267,8 @@ main(void)
else
while((c = fgetc(stdin)) != '\n' && c != EOF);
manage_input(input);
if(*input != '\0')
manage_input(input);
free(input);
}

View File

@ -18,6 +18,7 @@
exit, quit Quit wmfs-shell.\n\
uicb_list Print all uicb wmfs function.\n\
exec(<uicb func name>, <arg>) Execute a Wmfs uicb function.\n\
tag_set(<tag number>) Change the current tag\n\
statustext(text) Print text in the wmfs bar.\n\
spawn(<command>) Execute a system command.\n\n"
#define UICBLIST \

View File

@ -131,6 +131,7 @@ conf_misc_section(cfg_t *cfg_m)
void
conf_bar_section(cfg_t *cfg_b)
{
conf.border.bar = cfg_getbool(cfg_b, "border");
conf.colors.bar = getcolor(alias_to_str(cfg_getstr(cfg_b, "bg")));
conf.colors.text = strdup(alias_to_str(cfg_getstr(cfg_b, "fg")));
conf.bartop = (strcmp(strdup(cfg_getstr(cfg_b, "position")), "top") == 0) ? True : False;
@ -189,6 +190,7 @@ conf_layout_section(cfg_t *cfg_l)
conf.layout[i].func = NULL;
}
conf.border.layout = cfg_getbool(cfg_l, "border");
conf.colors.layout_fg = strdup(alias_to_str(cfg_getstr(cfg_l, "fg")));
conf.colors.layout_bg = getcolor(alias_to_str(cfg_getstr(cfg_l, "bg")));
@ -237,7 +239,7 @@ conf_tag_section(cfg_t *cfg_t)
conf.colors.tagselfg = strdup(alias_to_str(cfg_getstr(cfg_t, "sel_fg")));
conf.colors.tagselbg = getcolor(alias_to_str(cfg_getstr(cfg_t, "sel_bg")));
conf.colors.tag_occupied_bg = getcolor(alias_to_str(cfg_getstr(cfg_t, "occupied_bg")));
conf.colors.tagbord = getcolor(alias_to_str(cfg_getstr(cfg_t, "border")));
conf.border.tag = cfg_getbool(cfg_t, "border");
/* Alloc all */
conf.ntag = emalloc(screen_count(), sizeof(int));

View File

@ -50,6 +50,7 @@ cfg_opt_t bar_opts[] =
CFG_STR("bg", "#090909", CFGF_NONE),
CFG_STR("fg", "#6289A1", CFGF_NONE),
CFG_STR("position", "top", CFGF_NONE),
CFG_BOOL("border", cfg_false, CFGF_NONE),
CFG_END()
};
@ -105,6 +106,7 @@ cfg_opt_t layouts_opts[] =
{
CFG_STR("fg", "#FFFFFF", CFGF_NONE),
CFG_STR("bg", "#292929", CFGF_NONE),
CFG_BOOL("border", cfg_false, CFGF_NONE),
CFG_SEC("layout", layout_opts, CFGF_MULTI),
CFG_END()
};
@ -127,7 +129,7 @@ cfg_opt_t tags_opts[] =
CFG_STR("occupied_bg", "#003366", CFGF_NONE),
CFG_STR("sel_fg", "#FFFFFF", CFGF_NONE),
CFG_STR("sel_bg", "#354B5C", CFGF_NONE),
CFG_STR("border", "#090909", CFGF_NONE),
CFG_BOOL("border", cfg_false, CFGF_NONE),
CFG_SEC("tag", tag_opts, CFGF_MULTI),
CFG_END()
};

View File

@ -53,7 +53,7 @@ infobar_init(void)
/* Create infobar barwindow */
infobar[sc].bar = barwin_create(ROOT, sgeo[sc].x - BORDH, infobar[sc].geo.y,
sgeo[sc].width, infobar[sc].geo.height,
conf.colors.bar, conf.colors.text, False, False, True);
conf.colors.bar, conf.colors.text, False, False, conf.border.bar);
/* Create tags window */
for(i = 1; i < conf.ntag[sc] + 1; ++i)
@ -61,7 +61,7 @@ infobar_init(void)
infobar[sc].tags[i] = barwin_create(infobar[sc].bar->win, j, 0,
textw(tags[sc][i].name) + PAD,
infobar[sc].geo.height,
conf.colors.bar, conf.colors.text, False, False, True);
conf.colors.bar, conf.colors.text, False, False, conf.border.tag);
j += textw(tags[sc][i].name) + PAD;
barwin_map_subwin(infobar[sc].tags[i]);
}
@ -71,7 +71,7 @@ infobar_init(void)
textw(tags[sc][seltag[sc]].layout.symbol) + PAD,
infobar[sc].geo.height,
conf.colors.layout_bg, conf.colors.layout_fg,
False, False, True);
False, False, conf.border.layout);
/* Map/Refresh all */
barwin_map(infobar[sc].bar);

View File

@ -257,6 +257,12 @@ typedef struct
MouseBinding *mouse;
int nmouse;
} titlebar;
struct
{
Bool bar;
Bool tag;
Bool layout;
} border;
Alias alias[256];
Layout layout[NUM_OF_LAYOUT];
int *ntag;

6
wmfsrc
View File

@ -16,6 +16,7 @@ bar
{
bg = "#191919"
fg = "#D4D4D4"
border = true
position = "top"
}
@ -23,6 +24,8 @@ layouts
{
fg = "#191919"
bg = "#7E89A2"
# Border around the layout button
border = true
# Tiling layouts
layout { type = "tile_right" symbol = "RIGHT" }
@ -42,7 +45,8 @@ tags
occupied_bg = "#003366"
sel_fg = "#191919"
sel_bg = "#7E89A2"
border = "#3F485E"
# Border around the tag buttons
border = true
tag { screen = 1 name = "one" mwfact = 0.65 nmaster = 1 layout = "tile_right" resizehint = false }
tag { name = "two" }