diff --git a/docs/spmenu.conf b/docs/spmenu.conf index 00c4b13..aa59040 100644 --- a/docs/spmenu.conf +++ b/docs/spmenu.conf @@ -137,10 +137,10 @@ spmenu = { } ); /* Powerline options */ - powerline = ( { promptstyle = 0; // Prompt powerline style (0: >, 1: \) - matchcountstyle = 0; // Match count powerline style (0: <, 1: /) - modestyle = 0; // Mode indicator powerline style (0: <, 1: /) - capsstyle = 0; // Caps lock indicator powerline style (0: <, 1: /) + powerline = ( { promptstyle = 0; // Prompt powerline style (0: >, 1: \, 2: )) + matchcountstyle = 0; // Match count powerline style (0: <, 1: /, 2: () + modestyle = 0; // Mode indicator powerline style (0: <, 1: /, 2: () + capsstyle = 0; // Caps lock indicator powerline style (0: <, 1: /, 2: () prompt = 1; // Enable prompt powerline (0/1) matchcount = 1; // Enable match count powerline (0/1) mode = 1; // Enable mode indicator powerline (0/1) diff --git a/libs/draw.c b/libs/draw.c index 1bd54b3..910af7d 100644 --- a/libs/draw.c +++ b/libs/draw.c @@ -359,7 +359,12 @@ int drawprompt(int x, int y, int w) { x = drw_text(drw, x, y, w, bh, lrpad / 2, prompt, 0, pango_prompt ? True : False, col_promptfg, col_promptbg, alpha_promptfg, alpha_promptbg); if (!hidepowerline && powerlineprompt) { - drw_arrow(drw, x, y, plw, bh, 1, promptpwlstyle, col_menu, col_promptbg, alpha_menu, alpha_promptbg); + if (promptpwlstyle == 2) { + drw_circle(drw, x, y, plw, bh, 1, col_menu, col_promptbg, alpha_menu, alpha_promptbg); + } else { + drw_arrow(drw, x, y, plw, bh, 1, promptpwlstyle, col_menu, col_promptbg, alpha_menu, alpha_promptbg); + } + x += plw; } } @@ -433,7 +438,11 @@ int drawnumber(int x, int y, int w) { // draw powerline for match count if (!hidepowerline && powerlinecount) { - drw_arrow(drw, x, y, plw, bh, 0, matchcountpwlstyle, col_menu, col_numbg, alpha_menu, alpha_numbg); + if (matchcountpwlstyle == 2) { + drw_circle(drw, x, y, plw, bh, 0, col_menu, col_numbg, alpha_menu, alpha_numbg); + } else { + drw_arrow(drw, x, y, plw, bh, 0, matchcountpwlstyle, col_menu, col_numbg, alpha_menu, alpha_numbg); + } x += plw; } @@ -453,9 +462,15 @@ int drawmode(int x, int y, int w) { // draw powerline for match count if (!hidepowerline && powerlinemode) { - drw_arrow(drw, x, y, plw, bh, 0, modepwlstyle, - hidematchcount ? col_menu : col_numbg, col_modebg, - hidematchcount ? alpha_menu : alpha_numbg, alpha_modebg); + if (modepwlstyle == 2) { + drw_circle(drw, x, y, plw, bh, 0, + hidematchcount ? col_menu : col_numbg, col_modebg, + hidematchcount ? alpha_menu : alpha_numbg, alpha_modebg); + } else { + drw_arrow(drw, x, y, plw, bh, 0, modepwlstyle, + hidematchcount ? col_menu : col_numbg, col_modebg, + hidematchcount ? alpha_menu : alpha_numbg, alpha_modebg); + } x += plw; } @@ -478,9 +493,15 @@ int drawcaps(int x, int y, int w) { // draw powerline for caps lock indicator if (!hidepowerline && powerlinecaps) { - drw_arrow(drw, x, y, plw, bh, 0, capspwlstyle, - hidemode ? hidematchcount ? col_menu : col_numbg : col_modebg, col_capsbg, - hidemode ? hidematchcount ? alpha_menu : alpha_numbg : alpha_modebg, alpha_capsbg); + if (capspwlstyle == 2) { + drw_circle(drw, x, y, plw, bh, 0, + hidemode ? hidematchcount ? col_menu : col_numbg : col_modebg, col_capsbg, + hidemode ? hidematchcount ? alpha_menu : alpha_numbg : alpha_modebg, alpha_capsbg); + } else { + drw_arrow(drw, x, y, plw, bh, 0, capspwlstyle, + hidemode ? hidematchcount ? col_menu : col_numbg : col_modebg, col_capsbg, + hidemode ? hidematchcount ? alpha_menu : alpha_numbg : alpha_modebg, alpha_capsbg); + } x += plw; } diff --git a/libs/libdrw/drw.c b/libs/libdrw/drw.c index 756104e..97acadc 100644 --- a/libs/libdrw/drw.c +++ b/libs/libdrw/drw.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include "drw.h" #include "../sl/main.h" @@ -191,6 +191,45 @@ void drw_arrow(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direc cairo_surface_destroy(sf); } +void drw_circle(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direction, char *prevcol, char *nextcol, int prevalpha, int nextalpha) { + if (!drw) + return; + + cairo_surface_t *sf = NULL; + + if (drw->protocol) { + sf = cairo_image_surface_create_for_data(drw->data, CAIRO_FORMAT_ARGB32, drw->w, drw->h, drw->w * 4); + } else { + sf = cairo_xlib_surface_create(drw->dpy, drw->drawable, drw->visual, drw->w, drw->h); + } + + cairo_t *cr = cairo_create(sf); + + cairo_set_source_hex(cr, prevcol, prevalpha); + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); + + // draw rectangle + cairo_rectangle(cr, x, y, w, h); + cairo_fill(cr); + + double cx = direction ? x + w - h / 2.0 : x + h / 2.0; + double cy = y + h / 2; + double rad = h / 2.0; + + double start = direction ? -M_PI_2 : M_PI_2; + double end = direction ? M_PI_2 : 3 * M_PI_2; + + // draw circle + cairo_arc(cr, cx, cy, rad, start, end); + cairo_close_path(cr); + + cairo_set_source_hex(cr, nextcol, nextalpha); + cairo_fill(cr); + + cairo_destroy(cr); + cairo_surface_destroy(sf); +} + void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert, char *fgcol, char *bgcol, int fgalpha, int bgalpha) { if (!drw) { return; diff --git a/libs/libdrw/drw.h b/libs/libdrw/drw.h index c2a6268..70d0bf0 100644 --- a/libs/libdrw/drw.h +++ b/libs/libdrw/drw.h @@ -64,3 +64,4 @@ void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h) /* Powerline functions */ void drw_arrow(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direction, int slash, char *prevcol, char *nextcol, int prevalpha, int nextalpha); +void drw_circle(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direction, char *prevcol, char *nextcol, int prevalpha, int nextalpha); diff --git a/options.h b/options.h index 8ee8c5c..2a71bf7 100644 --- a/options.h +++ b/options.h @@ -40,10 +40,10 @@ static int powerlineprompt = 1; /* Enable powerline for the prompt * static int powerlinecount = 1; /* Enable powerline for the match count */ static int powerlinemode = 1; /* Enable powerline for the mode indicator */ static int powerlinecaps = 1; /* Enable powerline for the caps lock 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: /) */ -static int capspwlstyle = 0; /* Caps lock indicator powerline style (0: <, 1: /) */ +static int promptpwlstyle = 0; /* Prompt powerline style (0: >, 1: \, 2: )) */ +static int matchcountpwlstyle = 0; /* Match count powerline style (0: <, 1: /, 2: () */ +static int modepwlstyle = 0; /* Mode indicator powerline style (0: <, 1: /, 2: () */ +static int capspwlstyle = 0; /* Caps lock indicator powerline style (0: <, 1: /, 2: () */ /* Window properties */ static int dockproperty = 1; /* Set _NET_WM_WINDOW_TYPE_DOCK */