added launchers patch

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

@ -31,7 +31,7 @@ static const char *colors[][3] = {
[SchemeNorm] = { col_fg, col_bg, col_grey }, [SchemeNorm] = { col_fg, col_bg, col_grey },
[SchemeSel] = { col_grey, col_blue, col_orange }, [SchemeSel] = { col_grey, col_blue, col_orange },
/* Statusbar right { fg, bg, leave as-is} */ /* Statusbar right { fg, bg, leave as-is} */
[SchemeStatus] = { col_bg, col_green, "#000000" }, [SchemeStatus] = { col_bg, col_green, "#000000" },
/* Tagbar left selected */ /* Tagbar left selected */
[SchemeTagsSel] = { col_bg, col_aqua_0, "#000000" }, [SchemeTagsSel] = { col_bg, col_aqua_0, "#000000" },
/* Tagbar left unselected */ /* Tagbar left unselected */
@ -39,7 +39,9 @@ static const char *colors[][3] = {
/* infobar middle selected */ /* infobar middle selected */
[SchemeInfoSel] = { col_bg_0, col_purple, "#000000" }, [SchemeInfoSel] = { col_bg_0, col_purple, "#000000" },
/* infobar middle unselected */ /* infobar middle unselected */
[SchemeInfoNorm] = { col_fg, col_bg_0, "#000000" }, [SchemeInfoNorm] = { col_fg, col_bg_0, "#000000" },
/* Menu scheme */
[SchemeMenu] = { col_bg_0, col_yellow, "#000000" },
}; };
/* tagging */ /* tagging */
@ -83,6 +85,12 @@ static const char *roficmd[] = { "rofi", "-show", "drun", NULL };
static const char *rofiruncmd[] = { "rofi", "-show", "run", NULL}; static const char *rofiruncmd[] = { "rofi", "-show", "run", NULL};
static const char *termcmd[] = { "alacritty", NULL }; static const char *termcmd[] = { "alacritty", NULL };
/* launcher */
static const Launcher launchers[] = {
/* command name to display */
{ roficmd, "menu" },
};
static Key keys[] = { static Key keys[] = {
/* modifier key function argument */ /* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = roficmd } }, { MODKEY, XK_p, spawn, {.v = roficmd } },

36
dwm.c

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

Loading…
Cancel
Save