diff options
| -rw-r--r-- | config.def.h | 24 | ||||
| -rw-r--r-- | config.h | 32 | ||||
| -rw-r--r-- | dwm.c | 155 |
3 files changed, 31 insertions, 180 deletions
diff --git a/config.def.h b/config.def.h index 17947a7..b275b14 100644 --- a/config.def.h +++ b/config.def.h @@ -2,6 +2,7 @@ /* appearance */ static const unsigned int borderpx = 1; /* border pixel of windows */ +static const unsigned int gappx = 18; /* gap pixel between windows */ static const unsigned int snap = 32; /* snap pixel */ // systray @@ -10,13 +11,6 @@ static const unsigned int systrayspacing = 2; /* systray spacing */ static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/ static const int showsystray = 1; /* 0 means no systray */ -// vanity gaps -static const unsigned int gappih = 10; /* horiz inner gap between windows */ -static const unsigned int gappiv = 10; /* vert inner gap between windows */ -static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ -static const unsigned int gappov = 10; /* vert outer gap between windows and screen edge */ -static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */ - static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ static const int focusonwheel = 0; @@ -85,22 +79,6 @@ static Key keys[] = { { MODKEY, XK_d, incnmaster, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, - { MODKEY|Mod4Mask, XK_h, incrgaps, {.i = +1 } }, - { MODKEY|Mod4Mask, XK_l, incrgaps, {.i = -1 } }, - { MODKEY|Mod4Mask|ShiftMask, XK_h, incrogaps, {.i = +1 } }, - { MODKEY|Mod4Mask|ShiftMask, XK_l, incrogaps, {.i = -1 } }, - { MODKEY|Mod4Mask|ControlMask, XK_h, incrigaps, {.i = +1 } }, - { MODKEY|Mod4Mask|ControlMask, XK_l, incrigaps, {.i = -1 } }, - { MODKEY|Mod4Mask, XK_0, togglegaps, {0} }, - { MODKEY|Mod4Mask|ShiftMask, XK_0, defaultgaps, {0} }, - { MODKEY, XK_y, incrihgaps, {.i = +1 } }, - { MODKEY, XK_o, incrihgaps, {.i = -1 } }, - { MODKEY|ControlMask, XK_y, incrivgaps, {.i = +1 } }, - { MODKEY|ControlMask, XK_o, incrivgaps, {.i = -1 } }, - { MODKEY|Mod4Mask, XK_y, incrohgaps, {.i = +1 } }, - { MODKEY|Mod4Mask, XK_o, incrohgaps, {.i = -1 } }, - { MODKEY|ShiftMask, XK_y, incrovgaps, {.i = +1 } }, - { MODKEY|ShiftMask, XK_o, incrovgaps, {.i = -1 } }, { MODKEY, XK_Return, zoom, {0} }, { MODKEY, XK_Tab, view, {0} }, { MODKEY|ShiftMask, XK_c, killclient, {0} }, @@ -1,26 +1,20 @@ /* See LICENSE file for copyright and license details. */ /* appearance */ static const unsigned int borderpx = 3; /* border pixel of windows */ +static const unsigned int gappx = 10; /* gaps between windows */ static const unsigned int snap = 32; /* snap pixel */ // systray static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */ static const unsigned int systrayspacing = 2; /* systray spacing */ static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/ -static const int showsystray = 1; /* 0 means no systray */ - -// vanity gaps -static const unsigned int gappih = 10; /* horiz inner gap between windows */ -static const unsigned int gappiv = 10; /* vert inner gap between windows */ -static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ -static const unsigned int gappov = 10; /* vert outer gap between windows and screen edge */ -static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */ +static const int showsystray = 1; /* 0 means no systray */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 0; /* 0 means bottom bar */ static const int focusonwheel = 0; -static const char *fonts[] = { "monospace:size=10" }; -static const char dmenufont[] = "monospace:size=10"; +static const char *fonts[] = { "monospace:size=13" }; +static const char dmenufont[] = "monospace:size=13"; static const char col_gray1[] = "#222222"; static const char col_gray2[] = "#444444"; static const char col_gray3[] = "#bbbbbb"; @@ -53,8 +47,8 @@ static const int resizehints = 1; /* 1 means respect size hints in tiled resi static const Layout layouts[] = { /* symbol arrange function */ { "[]=", tile }, /* first entry is default */ - { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "><>", NULL }, /* no layout function means floating behavior */ }; /* key definitions */ @@ -70,15 +64,17 @@ static const Layout layouts[] = { /* commands */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; -static const char *termcmd[] = { "st", NULL }; +static const char *dmenucmd[] = { "dmenu_run", "-l", "10", "-i", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; +static const char *termcmd[] = { "st", NULL }; +static const char *browsercmd[] = { "firefox", NULL }; +static const char *filemanagercmd[] = { "st", "-e", "ranger", NULL }; #include <X11/XF86keysym.h> static Key keys[] = { /* modifier key function argument */ { MODKEY, XK_p, spawn, {.v = dmenucmd } }, { MODKEY, XK_Return, spawn, {.v = termcmd } }, - { MODKEY, XK_b, togglebar, {0} }, + { MODKEY, XK_slash, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, { MODKEY, XK_i, incnmaster, {.i = +1 } }, @@ -89,10 +85,10 @@ static Key keys[] = { { MODKEY, XK_Tab, view, {0} }, { MODKEY, XK_q, killclient, {0} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, - { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, - { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY, XK_m, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY, XK_f, togglefullscr, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } }, @@ -100,6 +96,10 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + // App bindings + { MODKEY, XK_w, spawn, {.v = browsercmd } }, + { MODKEY, XK_b, spawn, {.v = filemanagercmd } }, + // Volume control { 0, XF86XK_AudioMute, spawn, SHCMD("pamixer -t") }, { 0, XF86XK_AudioLowerVolume, spawn, SHCMD("pamixer --allow-boost -d 5") }, @@ -137,10 +137,6 @@ struct Monitor { int by; /* bar geometry */ int mx, my, mw, mh; /* screen size */ int wx, wy, ww, wh; /* window area */ - int gappih; /* horizontal gap between windows */ - int gappiv; /* vertical gap between windows */ - int gappoh; /* horizontal outer gaps */ - int gappov; /* vertical outer gaps */ unsigned int seltags; unsigned int sellt; unsigned int tagset[2]; @@ -230,16 +226,6 @@ static void sendmon(Client *c, Monitor *m); static void setclientstate(Client *c, long state); static void setfocus(Client *c); static void setfullscreen(Client *c, int fullscreen); -static void setgaps(int oh, int ov, int ih, int iv); -static void incrgaps(const Arg *arg); -static void incrigaps(const Arg *arg); -static void incrogaps(const Arg *arg); -static void incrohgaps(const Arg *arg); -static void incrovgaps(const Arg *arg); -static void incrihgaps(const Arg *arg); -static void incrivgaps(const Arg *arg); -static void togglegaps(const Arg *arg); -static void defaultgaps(const Arg *arg); static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); @@ -288,7 +274,6 @@ static char stext[256]; static int screen; static int sw, sh; /* X display screen geometry width, height */ static int bh, blw = 0; /* bar geometry */ -static int enablegaps = 1; /* enables gaps, used by togglegaps */ static int lrpad; /* sum of left and right padding for text */ static int (*xerrorxlib)(Display *, XErrorEvent *); static unsigned int numlockmask = 0; @@ -740,10 +725,6 @@ createmon(void) m->nmaster = nmaster; m->showbar = showbar; m->topbar = topbar; - m->gappih = gappih; - m->gappiv = gappiv; - m->gappoh = gappoh; - m->gappov = gappov; m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); @@ -1658,111 +1639,6 @@ setfullscreen(Client *c, int fullscreen) } void -setgaps(int oh, int ov, int ih, int iv) -{ - if (oh < 0) oh = 0; - if (ov < 0) ov = 0; - if (ih < 0) ih = 0; - if (iv < 0) iv = 0; - - selmon->gappoh = oh; - selmon->gappov = ov; - selmon->gappih = ih; - selmon->gappiv = iv; - arrange(selmon); -} - -void -togglegaps(const Arg *arg) -{ - enablegaps = !enablegaps; - arrange(selmon); -} - -void -defaultgaps(const Arg *arg) -{ - setgaps(gappoh, gappov, gappih, gappiv); -} - -void -incrgaps(const Arg *arg) -{ - setgaps( - selmon->gappoh + arg->i, - selmon->gappov + arg->i, - selmon->gappih + arg->i, - selmon->gappiv + arg->i - ); -} - -void -incrigaps(const Arg *arg) -{ - setgaps( - selmon->gappoh, - selmon->gappov, - selmon->gappih + arg->i, - selmon->gappiv + arg->i - ); -} - -void -incrogaps(const Arg *arg) -{ - setgaps( - selmon->gappoh + arg->i, - selmon->gappov + arg->i, - selmon->gappih, - selmon->gappiv - ); -} - -void -incrohgaps(const Arg *arg) -{ - setgaps( - selmon->gappoh + arg->i, - selmon->gappov, - selmon->gappih, - selmon->gappiv - ); -} - -void -incrovgaps(const Arg *arg) -{ - setgaps( - selmon->gappoh, - selmon->gappov + arg->i, - selmon->gappih, - selmon->gappiv - ); -} - -void -incrihgaps(const Arg *arg) -{ - setgaps( - selmon->gappoh, - selmon->gappov, - selmon->gappih + arg->i, - selmon->gappiv - ); -} - -void -incrivgaps(const Arg *arg) -{ - setgaps( - selmon->gappoh, - selmon->gappov, - selmon->gappih, - selmon->gappiv + arg->i - ); -} - -void setlayout(const Arg *arg) { if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) @@ -1947,32 +1823,29 @@ tagmon(const Arg *arg) void tile(Monitor *m) { - unsigned int i, n, h, r, oe = enablegaps, ie = enablegaps, mw, my, ty; + unsigned int i, n, h, mw, my, ty, ns; Client *c; for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); if (n == 0) return; - if (smartgaps == n) { - oe = 0; // outer gaps disabled + if (n > m->nmaster) { + mw = m->nmaster ? m->ww * m->mfact : 0; + ns = m->nmaster > 0 ? 2 : 1; + } else { + mw = m->ww; + ns = 1; } - - if (n > m->nmaster) - mw = m->nmaster ? (m->ww + m->gappiv*ie) * m->mfact : 0; - else - mw = m->ww - 2*m->gappov*oe + m->gappiv*ie; - for (i = 0, my = ty = m->gappoh*oe, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + for(i = 0, my = ty = gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) if (i < m->nmaster) { - r = MIN(n, m->nmaster) - i; - h = (m->wh - my - m->gappoh*oe - m->gappih*ie * (r - 1)) / r; - resize(c, m->wx + m->gappov*oe, m->wy + my, mw - (2*c->bw) - m->gappiv*ie, h - (2*c->bw), 0); - my += HEIGHT(c) + m->gappih*ie; + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - gappx; + resize(c, m->wx + gappx, m->wy + my, mw - (2*c->bw) - gappx*(5-ns)/2, h - (2*c->bw), False); + my += HEIGHT(c) + gappx; } else { - r = n - i; - h = (m->wh - ty - m->gappoh*oe - m->gappih*ie * (r - 1)) / r; - resize(c, m->wx + mw + m->gappov*oe, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappov*oe, h - (2*c->bw), 0); - ty += HEIGHT(c) + m->gappih*ie; + h = (m->wh - ty) / (n - i) - gappx; + resize(c, m->wx + mw + gappx/ns, m->wy + ty, m->ww - mw - (2*c->bw) - gappx*(5-ns)/2, h - (2*c->bw), False); + ty += HEIGHT(c) + gappx; } } |