added launchers patch

master
Alessandro Mauri 4 years ago
parent 3640c4a2b2
commit 12e03d2109
  1. 8
      config.h
  2. 36
      dwm.c

@ -40,6 +40,8 @@ static const char *colors[][3] = {
[SchemeInfoSel] = { col_bg_0, col_purple, "#000000" },
/* infobar middle unselected */
[SchemeInfoNorm] = { col_fg, col_bg_0, "#000000" },
/* Menu scheme */
[SchemeMenu] = { col_bg_0, col_yellow, "#000000" },
};
/* tagging */
@ -83,6 +85,12 @@ static const char *roficmd[] = { "rofi", "-show", "drun", NULL };
static const char *rofiruncmd[] = { "rofi", "-show", "run", NULL};
static const char *termcmd[] = { "alacritty", NULL };
/* launcher */
static const Launcher launchers[] = {
/* command name to display */
{ roficmd, "menu" },
};
static Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = roficmd } },

36
dwm.c

@ -60,7 +60,7 @@
/* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
enum { SchemeNorm, SchemeSel, SchemeStatus, SchemeTagsSel, SchemeTagsNorm, SchemeInfoSel, SchemeInfoNorm }; /* color schemes */
enum { SchemeNorm, SchemeSel, SchemeStatus, SchemeTagsSel, SchemeTagsNorm, SchemeInfoSel, SchemeInfoNorm, SchemeMenu }; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
@ -142,6 +142,11 @@ typedef struct {
int monitor;
} Rule;
typedef struct {
const char **command;
const char **name;
} Launcher;
/* function declarations */
static void applyrules(Client *c);
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
@ -439,9 +444,23 @@ buttonpress(XEvent *e)
if (i < LENGTH(tags)) {
click = ClkTagBar;
arg.ui = 1 << i;
} else if (ev->x < x + blw)
goto execute_handler;
} else if (ev->x < x + blw) {
click = ClkLtSymbol;
else if (ev->x > selmon->ww - TEXTW(stext))
goto execute_handler;
}
x += blw;
for (i = 0; i < LENGTH(launchers); i++) {
x += TEXTW(launchers[i].name);
if (ev->x < x) {
Arg a;
a.v = launchers[i].command;
spawn(&a);
return;
}
}
if (ev->x > selmon->ww - TEXTW(stext))
click = ClkStatusText;
else
click = ClkWinTitle;
@ -451,6 +470,9 @@ buttonpress(XEvent *e)
XAllowEvents(dpy, ReplayPointer, CurrentTime);
click = ClkClientWin;
}
execute_handler:
for (i = 0; i < LENGTH(buttons); i++)
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
@ -732,6 +754,14 @@ drawbar(Monitor *m)
drw_setscheme(drw, scheme[SchemeTagsNorm]);
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
/* Draw launchers */
for (i = 0; i < LENGTH(launchers); i++) {
w = TEXTW(launchers[i].name);
drw_setscheme(drw, scheme[SchemeMenu]);
drw_text(drw, x, 0, w, bh, lrpad / 2, launchers[i].name, urg & 1 << i);
x += w;
}
if ((w = m->ww - tw - x) > bh) {
if (n > 0) {
tw = TEXTW(m->sel->name) + lrpad;

Loading…
Cancel
Save