diff --git a/src/config.c b/src/config.c index f50872d..44ddaec 100644 --- a/src/config.c +++ b/src/config.c @@ -193,6 +193,7 @@ conf_bar_section(void) conf.selbar.bg = getcolor(fetch_opt_first(selbar, barbg, "bg").str); conf.selbar.fg = fetch_opt_first(selbar, conf.colors.text, "fg").str; + conf.selbar.maxlenght = fetch_opt_first(selbar, "-1", "max_lenght").num; mouse = fetch_section(selbar, "mouse"); diff --git a/src/infobar.c b/src/infobar.c index 6a9d250..6f5d0de 100644 --- a/src/infobar.c +++ b/src/infobar.c @@ -171,10 +171,12 @@ infobar_draw_layout(int sc) void infobar_draw_selbar(int sc) { + char *str = NULL; + if(!conf.bars.selbar) return; - if(!sel && infobar[sc].selbar->mapped) + if(!sel) { barwin_unmap(infobar[sc].selbar); return; @@ -182,17 +184,27 @@ infobar_draw_selbar(int sc) else if(sel && !infobar[sc].selbar->mapped) barwin_map(infobar[sc].selbar); + if(conf.selbar.maxlenght >= 0 && sel) + { + str = emalloc(conf.selbar.maxlenght + 4, sizeof(char)); + strncpy(str, sel->title, conf.selbar.maxlenght); + strcat(str, "..."); + } + + barwin_resize(infobar[sc].selbar, textw(str ? str : sel->title) + PAD, infobar[sc].geo.height - 2); + barwin_move(infobar[sc].selbar, ((conf.layout_placement) ? (infobar[sc].tags_board->geo.x + infobar[sc].tags_board->geo.width + PAD / 2) : (infobar[sc].layout_button->geo.x + infobar[sc].layout_button->geo.width + PAD / 2)), 1); - barwin_resize(infobar[sc].selbar, textw(sel ? sel->title : NULL) + PAD, infobar[sc].geo.height - 2); barwin_refresh_color(infobar[sc].selbar); - barwin_draw_text(infobar[sc].selbar, PAD / 2, FHINFOBAR - 1, (sel) ? sel->title : NULL); + barwin_draw_text(infobar[sc].selbar, PAD / 2, FHINFOBAR - 1, ((str) ? str : sel->title)); barwin_refresh(infobar[sc].selbar); + IFREE(str); + return; } diff --git a/src/structs.h b/src/structs.h index 8be90b2..4f123b5 100644 --- a/src/structs.h +++ b/src/structs.h @@ -376,6 +376,7 @@ typedef struct { char *fg; uint bg; + int maxlenght; MouseBinding *mouse; int nmouse; } selbar; diff --git a/wmfsrc.in b/wmfsrc.in index 4ceee76..3396c20 100644 --- a/wmfsrc.in +++ b/wmfsrc.in @@ -25,6 +25,9 @@ bg = "#191919" fg = "#D4D4ff" + # Cut title lenght + # max_lenght = 25 + [mouse] button = "3" func = "clientlist" [/mouse] [mouse] button = "4" func = "client_next" [/mouse] [mouse] button = "5" func = "client_prev" [/mouse]