dwm

dwm fork
git clone git://git.rr3.xyz/dwm
Log | Files | Refs | README | LICENSE

commit d90866eac5ae35626cc928d3783512691d49f061
parent e81f17d4c196aaed6893fd4beed49991caa3e2a4
Author: Robert Russell <robertrussell.72001@gmail.com>
Date:   Wed,  6 Sep 2023 14:05:49 -0700

rr3: custom changes

Diffstat:
Aconfig.h | 112+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdwm.c | 35+++++++++++++++++++++++++++++++++++
2 files changed, 147 insertions(+), 0 deletions(-)

diff --git a/config.h b/config.h @@ -0,0 +1,112 @@ +/* See LICENSE file for copyright and license details. */ + +/* appearance */ +static const unsigned int borderpx = 3; /* border pixel of windows */ +static const unsigned int snap = 32; /* snap pixel */ +static const int showbar = 1; /* 0 means no bar */ +static const int topbar = 1; /* 0 means bottom bar */ +static const char *fonts[] = { "monospace:size=16" }; +static const char dmenufont[] = "monospace:size=16"; +static const char col_gray1[] = "#222222"; +static const char col_gray2[] = "#444444"; +static const char col_gray3[] = "#bbbbbb"; +static const char col_gray4[] = "#eeeeee"; +static const char col_green[] = "#126912"; +static const char *colors[][3] = { + /* fg bg border */ + [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, + [SchemeSel] = { col_gray4, col_green, col_green }, +}; + +/* tagging */ +static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8" }; + +static const Rule rules[] = { + /* xprop(1): + * WM_CLASS(STRING) = instance, class + * WM_NAME(STRING) = title + */ + /* class instance title tags mask isfloating monitor */ + { "Firefox", NULL, NULL, 1 << 0, 0, -1 }, +}; + +/* layout(s) */ +static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ +static const int nmaster = 1; /* number of clients in master area */ +static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ +static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ + +static const Layout layouts[] = { + /* symbol arrange function */ + { "T", tile }, /* first entry is default */ + { "F", NULL }, /* no layout function means floating behavior */ + { "M", monocle }, +}; + +/* key definitions */ +#define MODKEY Mod4Mask +#define TAGKEYS(KEY,TAG) \ + { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ + { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ + { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ + { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, + +/* helper for spawning shell commands in the pre dwm-5.0 fashion */ +#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } + +/* 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_green, "-sf", col_gray4, NULL }; +static const char *volupcmd[] = { "volset", "+5%", NULL }; +static const char *voldowncmd[] = { "volset", "-5%", NULL }; +static const char *slockcmd[] = { "slock", NULL }; + +static const Key keys[] = { + /* modifier key function argument */ + { MODKEY, XK_space, spawn, {.v = dmenucmd } }, + { MODKEY, XK_l, spawn, {.v = slockcmd } }, + { MODKEY, XK_b, togglebar, {0} }, + { MODKEY, XK_Left, focusstack, {.i = +1 } }, + { MODKEY, XK_Right, focusstack, {.i = -1 } }, + { MODKEY, XK_Next, incnmaster, {.i = +1 } }, + { MODKEY, XK_Prior, incnmaster, {.i = -1 } }, + { MODKEY|ShiftMask, XK_Left, setmfact, {.f = -0.05} }, + { MODKEY|ShiftMask, XK_Right, setmfact, {.f = +0.05} }, + { MODKEY, XK_Return, zoom, {0} }, + { 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]} }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) + TAGKEYS( XK_4, 3) + TAGKEYS( XK_5, 4) + TAGKEYS( XK_6, 5) + TAGKEYS( XK_7, 6) + TAGKEYS( XK_8, 7) + { MODKEY|ShiftMask, XK_q, quit, {0} }, + { MODKEY, XK_z, slideview, {.i = -1} }, + { MODKEY, XK_x, slideview, {.i = +1} }, + + { 0, 0x1008ff13, spawn, { .v = volupcmd } }, + { 0, 0x1008ff11, spawn, { .v = voldowncmd } }, +}; + +/* button definitions */ +/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ +static const Button buttons[] = { + /* click event mask button function argument */ + { ClkLtSymbol, 0, Button1, setlayout, {0} }, + { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, + { ClkWinTitle, 0, Button2, zoom, {0} }, + { ClkClientWin, MODKEY, Button1, movemouse, {0} }, + { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, + { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, + { ClkTagBar, 0, Button1, view, {0} }, + { ClkTagBar, 0, Button3, toggleview, {0} }, + { ClkTagBar, MODKEY, Button1, tag, {0} }, + { ClkTagBar, MODKEY, Button3, toggletag, {0} }, +}; + diff --git a/dwm.c b/dwm.c @@ -186,6 +186,7 @@ static void motionnotify(XEvent *e); static void movemouse(const Arg *arg); static Client *nexttiled(Client *c); static void pop(Client *c); +static int popcnt(unsigned int x); static void propertynotify(XEvent *e); static void quit(const Arg *arg); static Monitor *recttomon(int x, int y, int w, int h); @@ -205,6 +206,8 @@ static void setmfact(const Arg *arg); static void setup(void); static void seturgent(Client *c, int urg); static void showhide(Client *c); +static void sigchld(int unused); +static void slideview(const Arg *arg); static void spawn(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); @@ -1218,6 +1221,15 @@ pop(Client *c) arrange(c->mon); } +int +popcnt(unsigned int x) +{ + int n = 0; + for (; x != 0; x &= x-1) + n += 1; + return n; +} + void propertynotify(XEvent *e) { @@ -1645,6 +1657,29 @@ showhide(Client *c) } void +sigchld(int unused) +{ + if (signal(SIGCHLD, sigchld) == SIG_ERR) + die("can't install SIGCHLD handler:"); + while (0 < waitpid(-1, NULL, WNOHANG)); +} + +void +slideview(const Arg *arg) +{ + int n = arg->i; + int tagset = selmon->tagset[selmon->seltags]; + if (popcnt(tagset) > 1) + return; + if (n < 0) + n += LENGTH(tags); + tagset = ((tagset << n) & TAGMASK) | (tagset >> (LENGTH(tags) - n)); + selmon->tagset[selmon->seltags] = tagset; + focus(NULL); + arrange(selmon); +} + +void spawn(const Arg *arg) { struct sigaction sa;