diff options
| author | ProsperousPotato <ProsperousPotato@users.noreply.github.com> | 2024-10-14 20:07:38 +0000 |
|---|---|---|
| committer | ProsperousPotato <ProsperousPotato@users.noreply.github.com> | 2025-03-31 18:31:28 +0100 |
| commit | 72176bd5550d4ddd5ff054676662a433299953ef (patch) | |
| tree | 3611a63a0a180b3aa3fdf3481bdd3fb05e7f22b4 | |
| parent | e372ecf49aff0344271c84061786fb5677ca0a78 (diff) | |
add gaps functionality
| -rw-r--r-- | config.def.h | 14 | ||||
| -rw-r--r-- | config.h | 14 | ||||
| -rw-r--r-- | dwm | bin | 77736 -> 77928 bytes | |||
| -rw-r--r-- | dwm.c | 35 | ||||
| -rw-r--r-- | dwm.o | bin | 68392 -> 69304 bytes |
5 files changed, 44 insertions, 19 deletions
diff --git a/config.def.h b/config.def.h index a824fcc..d5ee5ff 100644 --- a/config.def.h +++ b/config.def.h @@ -9,6 +9,7 @@ /* appearance */ static const unsigned int borderpx = 2; /* border pixel of windows */ static const unsigned int snap = 16; /* snap pixel */ +static const unsigned int gappx = 5; /* gaps between windows */ static const int swallowfloating = 1; /* 1 means swallow floating windows by default */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ @@ -131,15 +132,18 @@ static const Key keys[] = { { MODKEY|ShiftMask, XK_r, quit, {0} }, /* Non-default commands i.e. commands added in by me and patches */ - { MODKEY|ShiftMask, XK_space, spawn, {.v = sutermcmd } }, - { MODKEY|ControlMask, XK_space, spawn, {.v = floattermcmd } }, + { MODKEY|ShiftMask, XK_space, spawn, {.v = sutermcmd } }, + { MODKEY|ControlMask, XK_space, spawn, {.v = floattermcmd } }, + { MODKEY, XK_minus, setgaps, {.i = -1 } }, + { MODKEY, XK_equal, setgaps, {.i = +1 } }, + { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } }, { MODKEY|ShiftMask, XK_j, rotatestack, {.i = +1 } }, { MODKEY|ShiftMask, XK_k, rotatestack, {.i = -1 } }, { MODKEY, XK_g, spawn, SHCMD("~/.local/bin/./dmenu_games") }, { MODKEY|ShiftMask, XK_m, spawn, {.v = (const char*[]){ FLOATTERM, "-e", "neomutt", NULL } }}, { MODKEY|ShiftMask, XK_n, spawn, {.v = (const char*[]){ FLOATTERM, "-e", "nvim", NULL } }}, { MODKEY|ShiftMask, XK_h, spawn, {.v = (const char*[]){ FLOATTERM, "-e", "htop", NULL } }}, - { MODKEY, XK_e, spawn, {.v = (const char*[]){ FLOATTERM, "-e", "lfub", NULL } }}, + { MODKEY, XK_e, spawn, {.v = (const char*[]){ "pcmanfm", NULL } }}, { MODKEY, XK_Print, spawn, SHCMD("scrot -q 100 ~/Pictures/%Y-%m.jpg") }, { MODKEY, XK_Up, spawn, {.v = volumeup } }, { MODKEY, XK_Down, spawn, {.v = volumedown } }, @@ -156,7 +160,9 @@ static const Key keys[] = { { MODKEY, XK_w, spawn, {.v = browser } }, { MODKEY, XK_s, spawn, {.v = steam } }, { Mod1Mask|ControlMask, XK_Delete, spawn, {.v = slock } }, - { MODKEY, XK_v, spawn, SHCMD("xdotool type $(grep -v '^#' ~/.local/bin/bookmarksfile | dmenu -i -l 50)") }, + { MODKEY, XK_Insert, spawn, SHCMD("setxkmap gb; xdotool type $(grep -v '^#' ~/.local/bin/bookmarksfile | dmenu -i -l 50)") }, + { MODKEY, XK_v, spawn, SHCMD("~/.local/bin/qemu-dmenu") }, + { MODKEY, XK_c, spawn, SHCMD("~/.local/bin/calculator") }, { MODKEY|ShiftMask, XK_End, spawn, SHCMD("pkill X") }, }; @@ -9,6 +9,7 @@ /* appearance */ static const unsigned int borderpx = 2; /* border pixel of windows */ static const unsigned int snap = 16; /* snap pixel */ +static const unsigned int gappx = 5; /* gaps between windows */ static const int swallowfloating = 1; /* 1 means swallow floating windows by default */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ @@ -131,15 +132,18 @@ static const Key keys[] = { { MODKEY|ShiftMask, XK_r, quit, {0} }, /* Non-default commands i.e. commands added in by me and patches */ - { MODKEY|ShiftMask, XK_space, spawn, {.v = sutermcmd } }, - { MODKEY|ControlMask, XK_space, spawn, {.v = floattermcmd } }, + { MODKEY|ShiftMask, XK_space, spawn, {.v = sutermcmd } }, + { MODKEY|ControlMask, XK_space, spawn, {.v = floattermcmd } }, + { MODKEY, XK_minus, setgaps, {.i = -1 } }, + { MODKEY, XK_equal, setgaps, {.i = +1 } }, + { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } }, { MODKEY|ShiftMask, XK_j, rotatestack, {.i = +1 } }, { MODKEY|ShiftMask, XK_k, rotatestack, {.i = -1 } }, { MODKEY, XK_g, spawn, SHCMD("~/.local/bin/./dmenu_games") }, { MODKEY|ShiftMask, XK_m, spawn, {.v = (const char*[]){ FLOATTERM, "-e", "neomutt", NULL } }}, { MODKEY|ShiftMask, XK_n, spawn, {.v = (const char*[]){ FLOATTERM, "-e", "nvim", NULL } }}, { MODKEY|ShiftMask, XK_h, spawn, {.v = (const char*[]){ FLOATTERM, "-e", "htop", NULL } }}, - { MODKEY, XK_e, spawn, {.v = (const char*[]){ FLOATTERM, "-e", "lfub", NULL } }}, + { MODKEY, XK_e, spawn, {.v = (const char*[]){ "pcmanfm", NULL } }}, { MODKEY, XK_Print, spawn, SHCMD("scrot -q 100 ~/Pictures/%Y-%m.jpg") }, { MODKEY, XK_Up, spawn, {.v = volumeup } }, { MODKEY, XK_Down, spawn, {.v = volumedown } }, @@ -156,7 +160,9 @@ static const Key keys[] = { { MODKEY, XK_w, spawn, {.v = browser } }, { MODKEY, XK_s, spawn, {.v = steam } }, { Mod1Mask|ControlMask, XK_Delete, spawn, {.v = slock } }, - { MODKEY, XK_v, spawn, SHCMD("xdotool type $(grep -v '^#' ~/.local/bin/bookmarksfile | dmenu -i -l 50)") }, + { MODKEY, XK_Insert, spawn, SHCMD("setxkmap gb; xdotool type $(grep -v '^#' ~/.local/bin/bookmarksfile | dmenu -i -l 50)") }, + { MODKEY, XK_v, spawn, SHCMD("~/.local/bin/qemu-dmenu") }, + { MODKEY, XK_c, spawn, SHCMD("~/.local/bin/calculator") }, { MODKEY|ShiftMask, XK_End, spawn, SHCMD("pkill X") }, }; @@ -127,6 +127,7 @@ struct Monitor { int by; /* bar geometry */ int mx, my, mw, mh; /* screen size */ int wx, wy, ww, wh; /* window area */ + int gappx; /* gaps between windows */ unsigned int seltags; unsigned int sellt; unsigned int tagset[2]; @@ -214,6 +215,7 @@ 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(const Arg *arg); static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); @@ -723,6 +725,7 @@ createmon(void) m->nmaster = nmaster; m->showbar = showbar; m->topbar = topbar; + m->gappx = gappx; m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); @@ -1693,6 +1696,16 @@ setlayout(const Arg *arg) drawbar(selmon); } +void +setgaps(const Arg *arg) +{ + if ((arg->i == 0) || (selmon->gappx + arg->i < 0)) + selmon->gappx = 0; + else + selmon->gappx += arg->i; + arrange(selmon); +} + /* arg > 1.0 will set mfact absolutely */ void setmfact(const Arg *arg) @@ -1869,18 +1882,18 @@ tile(Monitor *m) if (n > m->nmaster) mw = m->nmaster ? m->ww * m->mfact : 0; else - mw = m->ww; - for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < m->nmaster) { - h = (m->wh - my) / (MIN(n, m->nmaster) - i); - resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); - if (my + HEIGHT(c) < m->wh) - my += HEIGHT(c); + mw = m->ww - m->gappx; + for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx; + resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0); + if (my + HEIGHT(c) + m->gappx < m->wh) + my += HEIGHT(c) + m->gappx; } else { - h = (m->wh - ty) / (n - i); - resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); - if (ty + HEIGHT(c) < m->wh) - ty += HEIGHT(c); + h = (m->wh - ty) / (n - i) - m->gappx; + resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0); + if (ty + HEIGHT(c) + m->gappx < m->wh) + ty += HEIGHT(c) + m->gappx; } } |
