diff --git a/docs/example.Xresources b/docs/example.Xresources index ce0889f..c6bc635 100644 --- a/docs/example.Xresources +++ b/docs/example.Xresources @@ -52,6 +52,14 @@ spmenu.col_sgrcolor13: #ff00ff spmenu.col_sgrcolor14: #00ffff spmenu.col_sgrcolor15: #ffffff +!! Powerline +spmenu.powerlineprompt: 1 +spmenu.powerlinecount: 1 +spmenu.powerlinemode: 1 +spmenu.promptpwlstyle: 0 +spmenu.matchcountpwlstyle: 0 +spmenu.modepwlstyle: 0 + !! Misc color spmenu.globalcolors: 1 spmenu.alpha: 1 diff --git a/docs/spmenu.conf b/docs/spmenu.conf index c82b279..e5cf387 100644 --- a/docs/spmenu.conf +++ b/docs/spmenu.conf @@ -82,6 +82,15 @@ spmenu = coloritems = 1; } ); + // Powerline options + powerline = ( { promptstyle = 0; + matchcountstyle = 0; + modestyle = 0; + prompt = 1; + matchcount = 1; + mode = 1; + } ); + // Hide options hide = ( { input = 0; larrow = 0; diff --git a/libs/conf/config.c b/libs/conf/config.c index ef770dd..4af53fe 100644 --- a/libs/conf/config.c +++ b/libs/conf/config.c @@ -100,6 +100,26 @@ conf_init(void) } } + // load options spmenu.powerline + setting = config_lookup(&cfg, "spmenu.powerline"); + if (setting != NULL) { + unsigned int i = 0; + + conflength = config_setting_length(setting); + + for (i = 0; i < conflength; ++i) { + config_setting_t *conf = config_setting_get_elem(setting, i); + + // look up + config_setting_lookup_int(conf, "promptstyle", &promptpwlstyle); // spmenu.powerline.promptstyle + config_setting_lookup_int(conf, "matchcountstyle", &matchcountpwlstyle); // spmenu.powerline.matchcountstyle + config_setting_lookup_int(conf, "modestyle", &modepwlstyle); // spmenu.powerline.modestyle + config_setting_lookup_int(conf, "prompt", &powerlineprompt); // spmenu.powerline.prompt + config_setting_lookup_int(conf, "matchcount", &powerlinecount); // spmenu.powerline.matchcount + config_setting_lookup_int(conf, "mode", &powerlinemode); // spmenu.powerline.mode + } + } + // load options spmenu.center setting = config_lookup(&cfg, "spmenu.center"); if (setting != NULL) { diff --git a/libs/draw.c b/libs/draw.c index a3efef4..8d1eed8 100644 --- a/libs/draw.c +++ b/libs/draw.c @@ -252,9 +252,9 @@ drawprompt(int x, int y, int w) x = drw_text(drw, x, y, w, bh, lrpad / 2, prompt, 0, pango_prompt ? True : False); - if (!hidepowerline) { + if (!hidepowerline && powerlineprompt) { drw_settrans(drw, scheme[SchemePrompt], scheme[SchemeMenu]); - drw_arrow(drw, x, y, plw, bh, 1, 0); + drw_arrow(drw, x, y, plw, bh, 1, promptpwlstyle); x += plw; } @@ -333,14 +333,19 @@ drawnumber(int x, int y, int w) { if (hidematchcount) return x; - drw_setscheme(drw, scheme[SchemeNumber]); + int powerlinewidth = 0; - drw_text(drw, x, y, w, bh, lrpad / 2 + plw / 2, numbers, 0, pango_numbers ? True : False); + if (!hidepowerline && powerlinecount) { + powerlinewidth = plw / 2; + } + + drw_setscheme(drw, scheme[SchemeNumber]); + drw_text(drw, x, y, w, bh, lrpad / 2 + powerlinewidth, numbers, 0, pango_numbers ? True : False); // draw powerline for match count - if (!hidepowerline) { + if (!hidepowerline && powerlinecount) { drw_settrans(drw, scheme[SchemeNumber], scheme[SchemeMenu]); - drw_arrow(drw, x, y, plw, bh, 0, 0); + drw_arrow(drw, x, y, plw, bh, 0, matchcountpwlstyle); x += plw; } @@ -352,14 +357,19 @@ int drawmode(int x, int y, int w) { if (!hidemode) { // draw mode indicator - drw_setscheme(drw, scheme[SchemeMode]); + int powerlinewidth = 0; - drw_text(drw, x, y, w, bh, lrpad / 2 + plw / 2, modetext, 0, pango_mode ? True : False); + if (!hidepowerline && powerlinemode) { + powerlinewidth = plw / 2; + } + + drw_setscheme(drw, scheme[SchemeMode]); + drw_text(drw, x, y, w, bh, lrpad / 2 + powerlinewidth, modetext, 0, pango_mode ? True : False); // draw powerline for match count - if (!hidepowerline) { + if (!hidepowerline && powerlinemode) { drw_settrans(drw, scheme[SchemeMode], hidematchcount ? scheme[SchemeMenu] : scheme[SchemeNumber]); - drw_arrow(drw, x, y, plw, bh, 0, 0); + drw_arrow(drw, x, y, plw, bh, 0, modepwlstyle); x += plw; } diff --git a/libs/mouse.c b/libs/mouse.c index 37350c5..acb9445 100644 --- a/libs/mouse.c +++ b/libs/mouse.c @@ -83,7 +83,7 @@ buttonpress(XEvent *e) click = clickwindow; // check if we clicked on the prompt or the input - if (ev->x < x + promptw + plw) { + if (ev->x < x + promptw + powerlineprompt ? plw : 0) { click = clickprompt; } else if (ev->x > mw - modeWidth - 2 * sp - 2 * borderwidth) { click = clickmode; diff --git a/libs/xresources.h b/libs/xresources.h index 44b9437..32bff16 100644 --- a/libs/xresources.h +++ b/libs/xresources.h @@ -48,6 +48,12 @@ ResourcePref resources[] = { { "col_sgrcolor15", STRING, &col_sgrcolor15 }, // General options + { "promptpwlstyle", INTEGER, &promptpwlstyle }, + { "matchcountpwlstyle", INTEGER, &matchcountpwlstyle }, + { "modepwlstyle", INTEGER, &modepwlstyle }, + { "powerlineprompt", INTEGER, &powerlineprompt }, + { "powerlinecount", INTEGER, &powerlinecount }, + { "powerlinemode", INTEGER, &powerlinemode }, { "dockproperty", INTEGER, &dockproperty }, { "globalcolors", INTEGER, &globalcolors }, { "coloritems", INTEGER, &coloritems }, diff --git a/options.h b/options.h index 58684bf..4e1d7fa 100644 --- a/options.h +++ b/options.h @@ -23,6 +23,14 @@ static int xpos = 0; /* X position to offset spmenu */ static int ypos = 0; /* Y position to offset spmenu */ static int managed = 0; /* Let your window manager manage spmenu? */ +/* Powerline options */ +static int powerlineprompt = 0; /* Enable powerline for the prompt */ +static int powerlinecount = 0; /* Enable powerline for the match count */ +static int powerlinemode = 0; /* Enable powerline for the mode indicator */ +static int promptpwlstyle = 0; /* Prompt powerline style (0: >, 1: \) */ +static int matchcountpwlstyle = 0; /* Match count powerline style (0: <, 1: /) */ +static int modepwlstyle = 0; /* Mode indicator powerline style (0: <, 1: /) */ + /* Window properties */ static int dockproperty = 1; /* Set _NET_WM_WINDOW_TYPE_DOCK */