Skip to content

Commit

Permalink
Add powerline icons to client titles
Browse files Browse the repository at this point in the history
  • Loading branch information
verschmelzen committed Jul 25, 2021
1 parent 293d0e4 commit 9149165
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
5 changes: 4 additions & 1 deletion dwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2361,7 +2361,6 @@ manage(Window w, XWindowAttributes *wa)
updatesizehints(c);
if (getatomprop(c, netatom[NetWMState]) == netatom[NetWMFullscreen])
setfullscreen(c, 1);
updatewmhints(c);
#if DECORATION_HINTS_PATCH
updatemotifhints(c);
#endif // DECORATION_HINTS_PATCH
Expand All @@ -2377,6 +2376,10 @@ manage(Window w, XWindowAttributes *wa)
c->sfw = c->w;
c->sfh = c->h;
#endif // SAVEFLOATS_PATCH / EXRESIZE_PATCH
#if ALWAYSCENTER_PATCH
c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2;
c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2;
#endif // ALWAYSCENTER_PATCH

XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
grabbuttons(c, 0);
Expand Down
17 changes: 12 additions & 5 deletions patch/bar_awesomebar.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ draw_awesomebar(Bar *bar, BarArg *a)
{
int n = 0, scm, remainder = 0, tabw, pad;
unsigned int i;
int plw = drw->fonts->h / 2 + 1;
#if BAR_TITLE_LEFT_PAD_PATCH && BAR_TITLE_RIGHT_PAD_PATCH
int x = a->x + lrpad / 2, w = a->w - lrpad;
#elif BAR_TITLE_LEFT_PAD_PATCH
int x = a->x + lrpad / 2, w = a->w - lrpad / 2;
#elif BAR_TITLE_RIGHT_PAD_PATCH
int x = a->x, w = a->w - lrpad / 2;
#else
int x = a->x, w = a->w;
int x = a->x, w = a->w - plw;
#endif // BAR_TITLE_LEFT_PAD_PATCH | BAR_TITLE_RIGHT_PAD_PATCH

Client *c;
Expand All @@ -26,7 +27,7 @@ draw_awesomebar(Bar *bar, BarArg *a)

if (n > 0) {
remainder = w % n;
tabw = w / n;
tabw = w / n - plw;
for (i = 0, c = bar->mon->clients; c; c = c->next, i++) {
if (!ISVISIBLE(c))
continue;
Expand All @@ -37,16 +38,22 @@ draw_awesomebar(Bar *bar, BarArg *a)
else
scm = SchemeTitleNorm;


pad = lrpad / 2;
#if BAR_CENTEREDWINDOWNAME_PATCH
if (TEXTW(c->name) < tabw)
pad = (tabw - TEXTW(c->name) + lrpad) / 2;
#endif // BAR_CENTEREDWINDOWNAME_PATCH

drw_setscheme(drw, scheme[scm]);
drw_text(drw, x, a->y, tabw + (i < remainder ? 1 : 0), a->h, pad, c->name, 0, False);
drawstateindicator(c->mon, c, 1, x, a->y, tabw + (i < remainder ? 1 : 0), a->h, 0, 0, c->isfixed);
x += tabw + (i < remainder ? 1 : 0);
drw_text(drw, x + plw, a->y, tabw + (i < remainder ? 1 : 0), a->h, pad, c->name, 0, False);
drawstateindicator(c->mon, c, 1, x + plw, a->y, tabw + (i < remainder ? 1 : 0), a->h, 0, 0, c->isfixed);
if (bar->mon->sel == c) {
drw_setscheme(drw, scheme[SchemeHid]);
drw_arrow(drw, x, a->y, plw, a->h, 0, 1);
drw_arrow(drw, x + tabw + plw, a->y, plw, a->h, 1, 1);
}
x += tabw + (i < remainder ? 1 : 0) + plw;
}
}
return n;
Expand Down
5 changes: 5 additions & 0 deletions patches.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@
*/
#define BAR_ALTTAGSDECORATION_PATCH 0

/* All floating windows are centered, like the center patch, but without a rule.
* https://dwm.suckless.org/patches/alwayscenter/
*/
#define ALWAYSCENTER_PATCH 0

/* This patch enables dwm to manage external status bars such as lemonbar and polybar.
* dwm treats the external bar as it would its own, so all regular dwm commands such as
* togglebar affect the external bar in the same way.
Expand Down

0 comments on commit 9149165

Please sign in to comment.