summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--Makefile13
-rw-r--r--README48
-rw-r--r--README.md25
-rw-r--r--config.def.h115
-rw-r--r--config.h372
-rw-r--r--drw.c15
-rw-r--r--drw.h2
-rw-r--r--dwm.1131
-rw-r--r--dwm.c440
-rwxr-xr-xdwmc40
-rw-r--r--larbs.mom346
-rw-r--r--shiftview.c36
-rw-r--r--vanitygaps.c481
14 files changed, 1749 insertions, 319 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b0d1779
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*.orig
+*.rej
+larbs.pdf
+patches
diff --git a/Makefile b/Makefile
index 77bcbc0..302a8cf 100644
--- a/Makefile
+++ b/Makefile
@@ -19,18 +19,15 @@ options:
${OBJ}: config.h config.mk
-config.h:
- cp config.def.h $@
-
dwm: ${OBJ}
${CC} -o $@ ${OBJ} ${LDFLAGS}
clean:
- rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
+ rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz *.orig *.rej
dist: clean
mkdir -p dwm-${VERSION}
- cp -R LICENSE Makefile README config.def.h config.mk\
+ cp -R LICENSE Makefile README config.mk\
dwm.1 drw.h util.h ${SRC} dwm.png transient.c dwm-${VERSION}
tar -cf dwm-${VERSION}.tar dwm-${VERSION}
gzip dwm-${VERSION}.tar
@@ -38,14 +35,18 @@ dist: clean
install: all
mkdir -p ${DESTDIR}${PREFIX}/bin
- cp -f dwm ${DESTDIR}${PREFIX}/bin
+ cp -f dwm dwmc ${DESTDIR}${PREFIX}/bin
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
mkdir -p ${DESTDIR}${MANPREFIX}/man1
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
+ mkdir -p ${DESTDIR}${PREFIX}/share/dwm
+ cp -f larbs.mom ${DESTDIR}${PREFIX}/share/dwm
+ chmod 644 ${DESTDIR}${PREFIX}/share/dwm/larbs.mom
uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/dwm\
+ ${DESTDIR}${PREFIX}/share/dwm/larbs.mom\
${DESTDIR}${MANPREFIX}/man1/dwm.1
.PHONY: all options clean dist install uninstall
diff --git a/README b/README
deleted file mode 100644
index 95d4fd0..0000000
--- a/README
+++ /dev/null
@@ -1,48 +0,0 @@
-dwm - dynamic window manager
-============================
-dwm is an extremely fast, small, and dynamic window manager for X.
-
-
-Requirements
-------------
-In order to build dwm you need the Xlib header files.
-
-
-Installation
-------------
-Edit config.mk to match your local setup (dwm is installed into
-the /usr/local namespace by default).
-
-Afterwards enter the following command to build and install dwm (if
-necessary as root):
-
- make clean install
-
-
-Running dwm
------------
-Add the following line to your .xinitrc to start dwm using startx:
-
- exec dwm
-
-In order to connect dwm to a specific display, make sure that
-the DISPLAY environment variable is set correctly, e.g.:
-
- DISPLAY=foo.bar:1 exec dwm
-
-(This will start dwm on display :1 of the host foo.bar.)
-
-In order to display status info in the bar, you can do something
-like this in your .xinitrc:
-
- while xsetroot -name "`date` `uptime | sed 's/.*,//'`"
- do
- sleep 1
- done &
- exec dwm
-
-
-Configuration
--------------
-The configuration of dwm is done by creating a custom config.h
-and (re)compiling the source code.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..0a2ef0a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,25 @@
+# Luke's build of dwm
+
+Here's my build of dwm.
+
+## FAQ
+
+> What are the bindings?
+
+This is suckless, mmmbud, the source code is the documentation! Check out `config.h`.
+
+## Patches and features
+
+- reads xresources colors
+- scratchpad accessible with mod+shift+enter
+- fibbonacci/centered master/etc. other layouts
+- true fullscreen and prevents focus shifting
+- windows can be made sticky
+- stacker patch
+- shiftview to cycle tags
+- gaps around windows and bar
+- dwmc
+
+## Please install `libxft-bgra`!
+
+This build of dwm does not block color emoji in the status/info bar, so you must install [libxft-bgra](https://aur.archlinux.org/packages/libxft-bgra/) from the AUR, which fixes a libxft color emoji rendering problem, otherwise dwm will crash upon trying to render one. Hopefully this fix will be in all libxft soon enough.
diff --git a/config.def.h b/config.def.h
deleted file mode 100644
index 1c0b587..0000000
--- a/config.def.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-
-/* appearance */
-static const unsigned int borderpx = 1; /* 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=10" };
-static const char dmenufont[] = "monospace:size=10";
-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_cyan[] = "#005577";
-static const char *colors[][3] = {
- /* fg bg border */
- [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
- [SchemeSel] = { col_gray4, col_cyan, col_cyan },
-};
-
-/* tagging */
-static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
-
-static const Rule rules[] = {
- /* xprop(1):
- * WM_CLASS(STRING) = instance, class
- * WM_NAME(STRING) = title
- */
- /* class instance title tags mask isfloating monitor */
- { "Gimp", NULL, NULL, 0, 1, -1 },
- { "Firefox", NULL, NULL, 1 << 8, 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 Layout layouts[] = {
- /* symbol arrange function */
- { "[]=", tile }, /* first entry is default */
- { "><>", NULL }, /* no layout function means floating behavior */
- { "[M]", monocle },
-};
-
-/* key definitions */
-#define MODKEY Mod1Mask
-#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_cyan, "-sf", col_gray4, NULL };
-static const char *termcmd[] = { "st", NULL };
-
-static Key keys[] = {
- /* modifier key function argument */
- { MODKEY, XK_p, spawn, {.v = dmenucmd } },
- { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
- { MODKEY, XK_b, togglebar, {0} },
- { MODKEY, XK_j, focusstack, {.i = +1 } },
- { MODKEY, XK_k, focusstack, {.i = -1 } },
- { MODKEY, XK_i, incnmaster, {.i = +1 } },
- { MODKEY, XK_d, incnmaster, {.i = -1 } },
- { MODKEY, XK_h, setmfact, {.f = -0.05} },
- { MODKEY, XK_l, setmfact, {.f = +0.05} },
- { MODKEY, XK_Return, zoom, {0} },
- { MODKEY, XK_Tab, view, {0} },
- { MODKEY|ShiftMask, XK_c, 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_space, setlayout, {0} },
- { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
- { MODKEY, XK_0, view, {.ui = ~0 } },
- { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
- { MODKEY, XK_comma, focusmon, {.i = -1 } },
- { MODKEY, XK_period, focusmon, {.i = +1 } },
- { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
- { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
- 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)
- TAGKEYS( XK_9, 8)
- { MODKEY|ShiftMask, XK_q, quit, {0} },
-};
-
-/* button definitions */
-/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
-static 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} },
- { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
- { 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/config.h b/config.h
new file mode 100644
index 0000000..a3163df
--- /dev/null
+++ b/config.h
@@ -0,0 +1,372 @@
+/* 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 unsigned int gappih = 20; /* 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 = 30; /* vert outer gap between windows and screen edge */
+static 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 char *fonts[] = { "monospace:size=10", "JoyPixels:pixelsize=10:antialias=true:autohint=true" };
+static char dmenufont[] = "monospace:size=10";
+static char normbgcolor[] = "#222222";
+static char normbordercolor[] = "#444444";
+static char normfgcolor[] = "#bbbbbb";
+static char selfgcolor[] = "#eeeeee";
+static char selbordercolor[] = "#005577";
+static char selbgcolor[] = "#005577";
+static char *colors[][3] = {
+ /* fg bg border */
+ [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
+ [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
+};
+
+/* tagging */
+static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+
+static const Rule rules[] = {
+ /* xprop(1):
+ * WM_CLASS(STRING) = instance, class
+ * WM_NAME(STRING) = title
+ */
+ /* class instance title tags mask isfloating monitor */
+ { "Gimp", NULL, NULL, 1 << 8, 0, -1 },
+ /* { "Firefox", NULL, NULL, 1 << 8, 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 */
+#define FORCE_VSPLIT 1 /* nrowgrid layout: force two clients to always split vertically */
+#include "vanitygaps.c"
+static const Layout layouts[] = {
+ /* symbol arrange function */
+ { "[]=", tile }, /* Default: Master on left, slaves on right */
+ { "TTT", bstack }, /* Master on top, slaves on bottom */
+
+ { "[@]", spiral }, /* Fibonacci spiral */
+ { "[\\]", dwindle }, /* Decreasing in size right and leftward */
+
+ { "H[]", deck }, /* Master on left, slaves in monocle-like mode on right */
+ { "[M]", monocle }, /* All windows on top of eachother */
+
+ { "|M|", centeredmaster }, /* Master in middle, slaves on sides */
+ { ">M>", centeredfloatingmaster }, /* Same but master floats */
+
+ { "><>", NULL }, /* no layout function means floating behavior */
+ { NULL, NULL },
+};
+
+/* 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} },
+#define STACKKEYS(MOD,ACTION) \
+ { MOD, XK_j, ACTION##stack, {.i = INC(+1) } }, \
+ { MOD, XK_k, ACTION##stack, {.i = INC(-1) } }, \
+ /* { MOD, XK_grave, ACTION##stack, {.i = PREVSEL } }, \ */
+ /* { MOD, XK_q, ACTION##stack, {.i = 0 } }, \ */
+ /* { MOD, XK_a, ACTION##stack, {.i = 1 } }, \ */
+ /* { MOD, XK_z, ACTION##stack, {.i = 2 } }, \ */
+ /* { MOD, XK_x, ACTION##stack, {.i = -1 } }, */
+
+/* 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", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL };
+static const char *termcmd[] = { "st", NULL };
+static const char scratchpadname[] = "scratchpad";
+static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL };
+
+/* PulseAudio commands. Require pulsemixer. */
+static const char *volup[] = { "pulsemixer", "--change-volume", "+5", NULL };
+static const char *bigvolup[] = { "pulsemixer", "--change-volume", "+15", NULL };
+static const char *voldown[] = { "pulsemixer", "--change-volume", "-5", NULL };
+static const char *bigvoldown[] = { "pulsemixer", "--change-volume", "-15", NULL };
+static const char *voltoggle[] = { "pulsemixer", "--toggle-mute", NULL };
+static const char *audiocontrol[] = { "st", "-e", "pulsemixer", NULL };
+
+/* ALSA commands. Requires amixer in alsa-utils. */
+/* static const char *volup[] = { "amixer", "sset", "Master", "5%+", NULL }; */
+/* static const char *bigvolup[] = { "amixer", "sset", "Master", "15%+", NULL }; */
+/* static const char *voldown[] = { "amixer", "sset", "Master", "5%-", NULL }; */
+/* static const char *bigvoldown[] = { "amixer", "sset", "Master", "15%-", NULL }; */
+/* static const char *voltoggle[] = { "amixer", "sset", "Master", "toggle" NULL }; */
+/* static const char *audiocontrol[] = { "st", "-e", "alsamixer", NULL }; */
+
+#include <X11/XF86keysym.h>
+#include "shiftview.c"
+static Key keys[] = {
+ /* modifier key function argument */
+ STACKKEYS(MODKEY, focus)
+ STACKKEYS(MODKEY|ShiftMask, push)
+ { MODKEY|ShiftMask, XK_Escape, spawn, SHCMD("[ \"$(printf \"No\\nYes\" | dmenu -i -nb darkred -sb red -sf white -nf gray -p \"Close dwm?\")\" = Yes ] && kill -TERM $(pidof dwm)") },
+ { MODKEY, XK_grave, spawn, SHCMD("dmenuunicode") },
+ /* { MODKEY|ShiftMask, XK_grave, togglescratch, SHCMD("") }, */
+ 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)
+ TAGKEYS( XK_9, 8)
+ { MODKEY, XK_0, view, {.ui = ~0 } },
+ { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
+ { MODKEY, XK_minus, spawn, {.v = voldown } },
+ { MODKEY|ShiftMask, XK_minus, spawn, {.v = bigvoldown } },
+ { MODKEY, XK_equal, spawn, {.v = volup } },
+ { MODKEY|ShiftMask, XK_equal, spawn, {.v = bigvolup } },
+ /* { MODKEY, XK_BackSpace, spawn, SHCMD("") }, */
+ { MODKEY|ShiftMask, XK_BackSpace, spawn, SHCMD("[ \"$(printf \"No\\nYes\" | dmenu -i -nb darkred -sb red -sf white -nf gray -p \"Reboot computer?\")\" = Yes ] && sudo -A reboot") },
+
+ { MODKEY, XK_Tab, view, {0} },
+ /* { MODKEY|ShiftMask, XK_Tab, spawn, SHCMD("") }, */
+ { MODKEY, XK_q, killclient, {0} },
+ /* { MODKEY|ShiftMask, XK_q, spawn, SHCMD("") }, */
+ { MODKEY, XK_w, spawn, SHCMD("$BROWSER") },
+ { MODKEY|ShiftMask, XK_w, spawn, SHCMD("st -e sudo nmtui") },
+ { MODKEY, XK_e, spawn, SHCMD("st -e neomutt ; pkill -RTMIN+12 dwmblocks; rmdir ~/.abook") },
+ { MODKEY|ShiftMask, XK_e, spawn, SHCMD("tutorialvids") },
+ { MODKEY, XK_r, spawn, SHCMD("st -e lf") },
+ { MODKEY|ShiftMask, XK_r, quit, {1} },
+ { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
+ { MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[1]} },
+ { MODKEY, XK_y, setlayout, {.v = &layouts[2]} },
+ { MODKEY|ShiftMask, XK_y, setlayout, {.v = &layouts[3]} },
+ { MODKEY, XK_u, setlayout, {.v = &layouts[4]} },
+ { MODKEY|ShiftMask, XK_u, setlayout, {.v = &layouts[5]} },
+ { MODKEY, XK_i, setlayout, {.v = &layouts[6]} },
+ { MODKEY|ShiftMask, XK_i, setlayout, {.v = &layouts[7]} },
+ { MODKEY, XK_o, incnmaster, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_o, incnmaster, {.i = -1 } },
+ { MODKEY, XK_p, spawn, SHCMD("mpc toggle") },
+ { MODKEY|ShiftMask, XK_p, spawn, SHCMD("mpc pause ; pauseallmpv") },
+ { MODKEY, XK_bracketleft, spawn, SHCMD("mpc seek -10") },
+ { MODKEY|ShiftMask, XK_bracketleft, spawn, SHCMD("mpc seek -120") },
+ { MODKEY, XK_bracketright, spawn, SHCMD("mpc seek +10") },
+ { MODKEY|ShiftMask, XK_bracketright, spawn, SHCMD("mpc seek +120") },
+ { MODKEY, XK_backslash, view, {0} },
+ /* { MODKEY|ShiftMask, XK_backslash, spawn, SHCMD("") }, */
+
+ { MODKEY, XK_a, spawn, {.v = audiocontrol } },
+ /* { MODKEY|ShiftMask, XK_a, spawn, SHCMD("") }, */
+ { MODKEY, XK_s, togglesticky, {0} },
+ /* { MODKEY|ShiftMask, XK_s, spawn, SHCMD("") }, */
+ { MODKEY, XK_d, spawn, {.v = dmenucmd } },
+ { MODKEY|ShiftMask, XK_d, togglegaps, {0} },
+ { MODKEY, XK_f, togglefullscr, {0} },
+ { MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[8]} },
+ { MODKEY, XK_g, shiftview, { .i = -1 } },
+ /* { MODKEY|ShiftMask, XK_g, spawn, SHCMD("") }, */
+ { MODKEY, XK_h, setmfact, {.f = -0.05} },
+ /* J and K are automatically bound above in STACKEYS */
+ { MODKEY, XK_l, setmfact, {.f = +0.05} },
+ { MODKEY, XK_semicolon, shiftview, { .i = 1 } },
+ /* { MODKEY|ShiftMask, XK_semicolon, shiftview, SHCMD("") }, */
+ /* { MODKEY, XK_apostrophe, spawn, SHCMD("") }, */
+ /* { MODKEY|ShiftMask, XK_apostrophe, spawn, SHCMD("") }, */
+ { MODKEY, XK_Return, spawn, {.v = termcmd } },
+ { MODKEY|ShiftMask, XK_Return, togglescratch, {.v = scratchpadcmd } },
+
+ { MODKEY, XK_z, incrgaps, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_z, incrgaps, {.i = -1 } },
+ { MODKEY, XK_x, spawn, SHCMD("slock & xset dpms force off; mpc pause ; pauseallmpv") },
+ { MODKEY|ShiftMask, XK_x, spawn, SHCMD("[ \"$(printf \"No\\nYes\" | dmenu -i -nb darkred -sb red -sf white -nf gray -p \"Shutdown computer?\")\" = Yes ] && sudo -A shutdown -h now") },
+ { MODKEY, XK_c, spawn, SHCMD("st -e bc -l") },
+ { MODKEY|ShiftMask, XK_c, spawn, SHCMD("mpv --no-cache --no-osc --no-input-default-bindings --input-conf=/dev/null --title=webcam $(ls /dev/video[0,2,4,6,8] | tail -n 1)") },
+ { MODKEY, XK_v, spawn, SHCMD("st -e $EDITOR -c \"VimwikiIndex\"") },
+ { MODKEY|ShiftMask, XK_v, spawn, SHCMD("{ killall xcompmgr || setsid xcompmgr & } ; xwallpaper --zoom ~/.config/wall.png") },
+ { MODKEY, XK_b, togglebar, {0} },
+ { MODKEY|ShiftMask, XK_b, spawn, SHCMD("hover left") },
+ { MODKEY, XK_n, spawn, SHCMD("st -e newsboat; pkill -RTMIN+6 dwmblocks") },
+ { MODKEY|ShiftMask, XK_n, spawn, SHCMD("hover right") },
+ { MODKEY, XK_m, spawn, SHCMD("st -e ncmpcpp") },
+ { MODKEY|ShiftMask, XK_m, spawn, {.v = voltoggle } },
+ { MODKEY, XK_comma, spawn, SHCMD("mpc prev") },
+ { MODKEY|ShiftMask, XK_comma, spawn, SHCMD("mpc seek 0%") },
+ { MODKEY, XK_period, spawn, SHCMD("mpc next") },
+ { MODKEY|ShiftMask, XK_period, spawn, SHCMD("mpc repeat") },
+
+ { MODKEY, XK_Left, focusmon, {.i = -1 } },
+ { MODKEY, XK_Left, focusmon, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_Right, tagmon, {.i = -1 } },
+ { MODKEY|ShiftMask, XK_Right, tagmon, {.i = +1 } },
+
+ { MODKEY, XK_Page_Up, shiftview, { .i = -1 } },
+ { MODKEY, XK_Page_Down, shiftview, { .i = 1 } },
+ { MODKEY, XK_Insert, spawn, SHCMD("notify-send \"📋 Clipboard contents:\" \"$(xclip -o -selection clipboard)\"") },
+
+ { MODKEY, XK_F1, spawn, SHCMD("groff -mom /usr/local/share/dwm/larbs.mom -Tpdf | zathura -") },
+ { MODKEY, XK_F2, quit, {1} },
+ { MODKEY, XK_F3, spawn, SHCMD("displayselect") },
+ { MODKEY, XK_F4, spawn, SHCMD("[ \"$(printf \"No\\nYes\" | dmenu -i -nb darkred -sb red -sf white -nf gray -p \"Hibernate computer?\")\" = Yes ] && sudo -A zzz") },
+ { MODKEY, XK_F5, xrdb, {.v = NULL } },
+ { MODKEY, XK_F6, spawn, SHCMD("torwrap") },
+ { MODKEY, XK_F7, spawn, SHCMD("td-toggle") },
+ { MODKEY, XK_F8, spawn, SHCMD("mailsync") },
+ { MODKEY, XK_F9, spawn, SHCMD("dmenumount") },
+ { MODKEY, XK_F10, spawn, SHCMD("dmenuumount") },
+ /* { MODKEY, XK_F11, spawn, SHCMD("") }, */
+ /* { MODKEY, XK_F12, spawn, SHCMD("") }, */
+ { MODKEY, XK_space, zoom, {0} },
+ { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+
+ { 0, XK_Print, spawn, SHCMD("maim pic-full-$(date '+%y%m%d-%H%M-%S').png") },
+ { ShiftMask, XK_Print, spawn, SHCMD("maimpick") },
+ { MODKEY, XK_Print, spawn, SHCMD("dmenurecord") },
+ { MODKEY|ShiftMask, XK_Print, spawn, SHCMD("dmenurecord kill") },
+ { MODKEY, XK_Delete, spawn, SHCMD("dmenurecord kill") },
+ { MODKEY, XK_Scroll_Lock, spawn, SHCMD("killall screenkey || screenkey &") },
+
+ { 0, XF86XK_AudioMute, spawn, {.v = voltoggle } },
+ { 0, XF86XK_AudioRaiseVolume, spawn, {.v = volup } },
+ { 0, XF86XK_AudioLowerVolume, spawn, {.v = voldown } },
+ { 0, XF86XK_AudioPrev, spawn, SHCMD("mpc prev") },
+ { 0, XF86XK_AudioNext, spawn, SHCMD("mpc next") },
+ { 0, XF86XK_AudioPause, spawn, SHCMD("mpc pause") },
+ { 0, XF86XK_AudioPlay, spawn, SHCMD("mpc play") },
+ { 0, XF86XK_AudioStop, spawn, SHCMD("mpc stop") },
+ { 0, XF86XK_AudioRewind, spawn, SHCMD("mpc seek -10") },
+ { 0, XF86XK_AudioForward, spawn, SHCMD("mpc seek +10") },
+ { 0, XF86XK_AudioMedia, spawn, SHCMD("st -e ncmpcpp") },
+ { 0, XF86XK_PowerOff, spawn, SHCMD("[ \"$(printf \"No\\nYes\" | dmenu -i -nb darkred -sb red -sf white -nf gray -p \"Shutdown computer?\")\" = Yes ] && sudo -A shutdown -h now") },
+ { 0, XF86XK_Calculator, spawn, SHCMD("st -e bc -l") },
+ { 0, XF86XK_Sleep, spawn, SHCMD("[ \"$(printf \"No\\nYes\" | dmenu -i -nb darkred -sb red -sf white -nf gray -p \"Hibernate computer?\")\" = Yes ] && sudo -A zzz") },
+ { 0, XF86XK_WWW, spawn, SHCMD("$BROWSER") },
+ { 0, XF86XK_DOS, spawn, SHCMD("st") },
+ { 0, XF86XK_ScreenSaver, spawn, SHCMD("slock & xset dpms force off; mpc pause; pauseallmpv") },
+ { 0, XF86XK_TaskPane, spawn, SHCMD("st -e htop") },
+ { 0, XF86XK_Mail, spawn, SHCMD("st -e neomutt ; pkill -RTMIN+12 dwmblocks") },
+ { 0, XF86XK_MyComputer, spawn, SHCMD("st -e lf /") },
+ /* { 0, XF86XK_Battery, spawn, SHCMD("") }, */
+ { 0, XF86XK_Launch1, spawn, SHCMD("xset dpms force off") },
+ { 0, XF86XK_TouchpadToggle, spawn, SHCMD("(synclient | grep 'TouchpadOff.*1' && synclient TouchpadOff=0) || synclient TouchpadOff=1") },
+ { 0, XF86XK_TouchpadOff, spawn, SHCMD("synclient TouchpadOff=1") },
+ { 0, XF86XK_TouchpadOn, spawn, SHCMD("synclient TouchpadOff=0") },
+ { 0, XF86XK_MonBrightnessUp, spawn, SHCMD("xbacklight -inc 15") },
+ { 0, XF86XK_MonBrightnessDown, spawn, SHCMD("xbacklight -dec 15") },
+
+ /* { 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|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 } }, */
+
+
+};
+
+/* button definitions */
+/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
+static 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} },
+ { ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1} },
+ { ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} },
+ { ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3} },
+ { ClkStatusText, 0, Button4, sigdwmblocks, {.i = 4} },
+ { ClkStatusText, 0, Button5, sigdwmblocks, {.i = 5} },
+ { 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} },
+ { ClkTagBar, 0, Button4, shiftview, {.i = -1} },
+ { ClkTagBar, 0, Button5, shiftview, {.i = 1} },
+};
+
+void
+setlayoutex(const Arg *arg)
+{
+ setlayout(&((Arg) { .v = &layouts[arg->i] }));
+}
+
+void
+viewex(const Arg *arg)
+{
+ view(&((Arg) { .ui = 1 << arg->ui }));
+}
+
+void
+viewall(const Arg *arg)
+{
+ view(&((Arg){.ui = ~0}));
+}
+
+void
+toggleviewex(const Arg *arg)
+{
+ toggleview(&((Arg) { .ui = 1 << arg->ui }));
+}
+
+void
+tagex(const Arg *arg)
+{
+ tag(&((Arg) { .ui = 1 << arg->ui }));
+}
+
+void
+toggletagex(const Arg *arg)
+{
+ toggletag(&((Arg) { .ui = 1 << arg->ui }));
+}
+
+void
+tagall(const Arg *arg)
+{
+ tag(&((Arg){.ui = ~0}));
+}
+
+/* signal definitions */
+/* signum must be greater than 0 */
+/* trigger signals using `xsetroot -name "fsignal:<signame> [<type> <value>]"` */
+static Signal signals[] = {
+ /* signum function */
+ { "focusstack", focusstack },
+ { "setmfact", setmfact },
+ { "togglebar", togglebar },
+ { "incnmaster", incnmaster },
+ { "togglefloating", togglefloating },
+ { "focusmon", focusmon },
+ { "tagmon", tagmon },
+ { "zoom", zoom },
+ { "view", view },
+ { "viewall", viewall },
+ { "viewex", viewex },
+ { "toggleview", view },
+ { "toggleviewex", toggleviewex },
+ { "tag", tag },
+ { "tagall", tagall },
+ { "tagex", tagex },
+ { "toggletag", tag },
+ { "toggletagex", toggletagex },
+ { "killclient", killclient },
+ { "quit", quit },
+ { "setlayout", setlayout },
+ { "setlayoutex", setlayoutex },
+ { "xrdb", xrdb },
+};
diff --git a/drw.c b/drw.c
index 8fd1ca4..0eb8fe5 100644
--- a/drw.c
+++ b/drw.c
@@ -132,19 +132,6 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
die("no font specified.");
}
- /* Do not allow using color fonts. This is a workaround for a BadLength
- * error from Xft with color glyphs. Modelled on the Xterm workaround. See
- * https://bugzilla.redhat.com/show_bug.cgi?id=1498269
- * https://lists.suckless.org/dev/1701/30932.html
- * https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349
- * and lots more all over the internet.
- */
- FcBool iscol;
- if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
- XftFontClose(drw->dpy, xfont);
- return NULL;
- }
-
font = ecalloc(1, sizeof(Fnt));
font->xfont = xfont;
font->pattern = pattern;
@@ -207,7 +194,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
/* Wrapper to create color schemes. The caller has to call free(3) on the
* returned color scheme when done using it. */
Clr *
-drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
+drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount)
{
size_t i;
Clr *ret;
diff --git a/drw.h b/drw.h
index 4bcd5ad..42b04ce 100644
--- a/drw.h
+++ b/drw.h
@@ -39,7 +39,7 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in
/* Colorscheme abstraction */
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
-Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
+Clr *drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount);
/* Cursor abstraction */
Cur *drw_cur_create(Drw *drw, int shape);
diff --git a/dwm.1 b/dwm.1
index 13b3729..8c457b5 100644
--- a/dwm.1
+++ b/dwm.1
@@ -1,21 +1,16 @@
.TH DWM 1 dwm\-VERSION
.SH NAME
-dwm \- dynamic window manager
+dwm \- dynamic window manager (Luke Smith <https://lukesmith.xyz>'s build)
.SH SYNOPSIS
.B dwm
.RB [ \-v ]
.SH DESCRIPTION
-dwm is a dynamic window manager for X. It manages windows in tiled, monocle
-and floating layouts. Either layout can be applied dynamically, optimising the
-environment for the application in use and the task performed.
+dwm is a dynamic window manager for X.
.P
-In tiled layouts windows are managed in a master and stacking area. The master
-area on the left contains one window by default, and the stacking area on the
-right contains all other windows. The number of master area windows can be
-adjusted from zero to an arbitrary number. In monocle layout all windows are
-maximised to the screen size. In floating layout windows can be resized and
-moved freely. Dialog windows are always managed floating, regardless of the
-layout applied.
+dwm "orders" windows based on recency and primacy, while dwm layouts may
+change, the most recent "master" window is shown in the most prominent
+position. There are bindings for cycling through and promoting windows to the
+master position.
.P
Windows are grouped by tags. Each window can be tagged with one or multiple
tags. Selecting certain tags displays all windows with these tags.
@@ -30,6 +25,15 @@ top left corner. The tags which are applied to one or more windows are
indicated with an empty square in the top left corner.
.P
dwm draws a small border around windows to indicate the focus state.
+.P
+.I
+libxft-bgra
+should be installed for this build of dwm. Arch users may install it via the
+AUR. Color characters and emoji are inabled, but these will cause crashes
+without the fix
+.I
+libxft-bgra
+offers.
.SH OPTIONS
.TP
.B \-v
@@ -42,119 +46,120 @@ is read and displayed in the status text area. It can be set with the
.BR xsetroot (1)
command.
.TP
-.B Button1
+.B Left click
click on a tag label to display all windows with that tag, click on the layout
label toggles between tiled and floating layout.
.TP
-.B Button3
+.B Right click
click on a tag label adds/removes all windows with that tag to/from the view.
.TP
-.B Mod1\-Button1
+.B Super\-Left click
click on a tag label applies that tag to the focused window.
.TP
-.B Mod1\-Button3
+.B Super\-Right click
click on a tag label adds/removes that tag to/from the focused window.
.SS Keyboard commands
.TP
-.B Mod1\-Shift\-Return
-Start
+.B Super\-Return
+Start terminal,
.BR st(1).
.TP
-.B Mod1\-p
+.B Super\-d
Spawn
.BR dmenu(1)
for launching other programs.
.TP
-.B Mod1\-,
-Focus previous screen, if any.
-.TP
-.B Mod1\-.
-Focus next screen, if any.
+.B Super\-b
+Toggles bar on and off.
.TP
-.B Mod1\-Shift\-,
-Send focused window to previous screen, if any.
+.B Super\-q
+Close focused window.
.TP
-.B Mod1\-Shift\-.
-Send focused window to next screen, if any.
+.B Super\-t
+Sets tiled layout.
.TP
-.B Mod1\-b
-Toggles bar on and off.
+.B Super\-f
+Toggle fullscreen window.
.TP
-.B Mod1\-t
-Sets tiled layout.
+.B Super\-y
+Sets Fibonacci spiral layout.
.TP
-.B Mod1\-f
-Sets floating layout.
+.B Super\-u
+Sets centered master layout.
.TP
-.B Mod1\-m
-Sets monocle layout.
+.B Super\-i
+Sets floating centered master layout.
.TP
-.B Mod1\-space
-Toggles between current and previous layout.
+.B Super\-space
+Zooms/cycles focused window to/from master area (tiled layouts only).
.TP
-.B Mod1\-j
-Focus next window.
+.B Super\-j/k
+Focus next/previous window.
.TP
-.B Mod1\-k
-Focus previous window.
+.B Super\-Shift\-j/k
+Move selected window down/up in stack.
.TP
-.B Mod1\-i
+.B Super\-o
Increase number of windows in master area.
.TP
-.B Mod1\-d
+.B Super\-Shift\-o
Decrease number of windows in master area.
.TP
-.B Mod1\-l
+.B Super\-l
Increase master area size.
.TP
-.B Mod1\-h
+.B Super\-h
Decrease master area size.
.TP
-.B Mod1\-Return
-Zooms/cycles focused window to/from master area (tiled layouts only).
-.TP
-.B Mod1\-Shift\-c
-Close focused window.
-.TP
-.B Mod1\-Shift\-space
+.B Super\-Shift\-space
Toggle focused window between tiled and floating state.
.TP
-.B Mod1\-Tab
+.B Super\-Tab
Toggles to the previously selected tags.
.TP
-.B Mod1\-Shift\-[1..n]
+.B Super\-Shift\-[1..n]
Apply nth tag to focused window.
.TP
-.B Mod1\-Shift\-0
+.B Super\-Shift\-0
Apply all tags to focused window.
.TP
-.B Mod1\-Control\-Shift\-[1..n]
+.B Super\-Control\-Shift\-[1..n]
Add/remove nth tag to/from focused window.
.TP
-.B Mod1\-[1..n]
+.B Super\-[1..n]
View all windows with nth tag.
.TP
-.B Mod1\-0
+.B Super\-0
View all windows with any tag.
.TP
-.B Mod1\-Control\-[1..n]
+.B Super\-Control\-[1..n]
Add/remove all windows with nth tag to/from the view.
.TP
-.B Mod1\-Shift\-q
+.B Super\-Shift\-q
Quit dwm.
+.TP
+.B Mod1\-Control\-Shift\-q
+Restart dwm.
.SS Mouse commands
.TP
-.B Mod1\-Button1
+.B Super\-Left click
Move focused window while dragging. Tiled windows will be toggled to the floating state.
.TP
-.B Mod1\-Button2
+.B Super\-Middle click
Toggles focused window between floating and tiled state.
.TP
-.B Mod1\-Button3
+.B Super\-Right click
Resize focused window while dragging. Tiled windows will be toggled to the floating state.
.SH CUSTOMIZATION
dwm is customized by creating a custom config.h and (re)compiling the source
code. This keeps it fast, secure and simple.
+.SH SIGNALS
+.TP
+.B SIGHUP - 1
+Restart the dwm process.
+.TP
+.B SIGTERM - 15
+Cleanly terminate the dwm process.
.SH SEE ALSO
.BR dmenu (1),
.BR st (1)
diff --git a/dwm.c b/dwm.c
index 4465af1..22dd0ca 100644
--- a/dwm.c
+++ b/dwm.c
@@ -35,6 +35,7 @@
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xproto.h>
+#include <X11/Xresource.h>
#include <X11/Xutil.h>
#ifdef XINERAMA
#include <X11/extensions/Xinerama.h>
@@ -47,15 +48,36 @@
/* macros */
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
+#define GETINC(X) ((X) - 2000)
+#define INC(X) ((X) + 2000)
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
-#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
+#define ISINC(X) ((X) > 1000 && (X) < 3000)
+#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]) || C->issticky)
+#define PREVSEL 3000
#define LENGTH(X) (sizeof X / sizeof X[0])
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
+#define MOD(N,M) ((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M))
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
#define TAGMASK ((1 << LENGTH(tags)) - 1)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
+#define TRUNC(X,A,B) (MAX((A), MIN((X), (B))))
+#define XRDB_LOAD_COLOR(R,V) if (XrmGetResource(xrdb, R, NULL, &type, &value) == True) { \
+ if (value.addr != NULL && strnlen(value.addr, 8) == 7 && value.addr[0] == '#') { \
+ int i = 1; \
+ for (; i <= 6; i++) { \
+ if (value.addr[i] < 48) break; \
+ if (value.addr[i] > 57 && value.addr[i] < 65) break; \
+ if (value.addr[i] > 70 && value.addr[i] < 97) break; \
+ if (value.addr[i] > 102) break; \
+ } \
+ if (i == 7) { \
+ strncpy(V, value.addr, 7); \
+ V[7] = '\0'; \
+ } \
+ } \
+ }
/* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
@@ -92,7 +114,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
unsigned int tags;
- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, issticky;
Client *next;
Client *snext;
Monitor *mon;
@@ -107,6 +129,11 @@ typedef struct {
} Key;
typedef struct {
+ const char * sig;
+ void (*func)(const Arg *);
+} Signal;
+
+typedef struct {
const char *symbol;
void (*arrange)(Monitor *);
} Layout;
@@ -119,6 +146,10 @@ 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];
@@ -148,6 +179,7 @@ static void arrange(Monitor *m);
static void arrangemon(Monitor *m);
static void attach(Client *c);
static void attachstack(Client *c);
+static int fake_signal(void);
static void buttonpress(XEvent *e);
static void checkotherwm(void);
static void cleanup(void);
@@ -156,6 +188,7 @@ static void clientmessage(XEvent *e);
static void configure(Client *c);
static void configurenotify(XEvent *e);
static void configurerequest(XEvent *e);
+static void copyvalidchars(char *text, char *rawtext);
static Monitor *createmon(void);
static void destroynotify(XEvent *e);
static void detach(Client *c);
@@ -169,6 +202,7 @@ static void focus(Client *c);
static void focusin(XEvent *e);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
+static int getdwmblockspid();
static int getrootptr(int *x, int *y);
static long getstate(Window w);
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
@@ -177,6 +211,7 @@ static void grabkeys(void);
static void incnmaster(const Arg *arg);
static void keypress(XEvent *e);
static void killclient(const Arg *arg);
+static void loadxrdb(void);
static void manage(Window w, XWindowAttributes *wa);
static void mappingnotify(XEvent *e);
static void maprequest(XEvent *e);
@@ -186,6 +221,7 @@ static void movemouse(const Arg *arg);
static Client *nexttiled(Client *c);
static void pop(Client *);
static void propertynotify(XEvent *e);
+static void pushstack(const Arg *arg);
static void quit(const Arg *arg);
static Monitor *recttomon(int x, int y, int w, int h);
static void resize(Client *c, int x, int y, int w, int h, int interact);
@@ -193,6 +229,7 @@ static void resizeclient(Client *c, int x, int y, int w, int h);
static void resizemouse(const Arg *arg);
static void restack(Monitor *m);
static void run(void);
+static void runAutostart(void);
static void scan(void);
static int sendevent(Client *c, Atom proto);
static void sendmon(Client *c, Monitor *m);
@@ -205,12 +242,18 @@ static void setup(void);
static void seturgent(Client *c, int urg);
static void showhide(Client *c);
static void sigchld(int unused);
+static void sigdwmblocks(const Arg *arg);
+static void sighup(int unused);
+static void sigterm(int unused);
static void spawn(const Arg *arg);
+static int stackpos(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
-static void tile(Monitor *);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
+static void togglesticky(const Arg *arg);
+static void togglefullscr(const Arg *arg);
+static void togglescratch(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unfocus(Client *c, int setfocus);
@@ -232,11 +275,15 @@ static Monitor *wintomon(Window w);
static int xerror(Display *dpy, XErrorEvent *ee);
static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
+static void xrdb(const Arg *arg);
static void zoom(const Arg *arg);
/* variables */
static const char broken[] = "broken";
static char stext[256];
+static char rawstext[256];
+static int dwmblockssig;
+pid_t dwmblockspid = 0;
static int screen;
static int sw, sh; /* X display screen geometry width, height */
static int bh, blw = 0; /* bar geometry */
@@ -260,6 +307,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
[UnmapNotify] = unmapnotify
};
static Atom wmatom[WMLast], netatom[NetLast];
+static int restart = 0;
static int running = 1;
static Cur *cursor[CurLast];
static Clr **scheme;
@@ -271,6 +319,8 @@ static Window root, wmcheckwin;
/* configuration, allows nested code to access above variables */
#include "config.h"
+static unsigned int scratchtag = 1 << LENGTH(tags);
+
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
@@ -416,7 +466,7 @@ attachstack(Client *c)
void
buttonpress(XEvent *e)
{
- unsigned int i, x, click;
+ unsigned int i, x, click, occ = 0;
Arg arg = {0};
Client *c;
Monitor *m;
@@ -431,17 +481,39 @@ buttonpress(XEvent *e)
}
if (ev->window == selmon->barwin) {
i = x = 0;
- do
+ for (c = m->clients; c; c = c->next)
+ occ |= c->tags == 255 ? 0 : c->tags;
+ do {
+ /* do not reserve space for vacant tags */
+ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
+ continue;
x += TEXTW(tags[i]);
- while (ev->x >= x && ++i < LENGTH(tags));
+ } while (ev->x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
click = ClkTagBar;
arg.ui = 1 << i;
} else if (ev->x < x + blw)
click = ClkLtSymbol;
- else if (ev->x > selmon->ww - TEXTW(stext))
+ else if (ev->x > (x = selmon->ww - TEXTW(stext) + lrpad)) {
click = ClkStatusText;
- else
+
+ char *text = rawstext;
+ int i = -1;
+ char ch;
+ dwmblockssig = 0;
+ while (text[++i]) {
+ if ((unsigned char)text[i] < ' ') {
+ ch = text[i];
+ text[i] = '\0';
+ x += TEXTW(text) - lrpad;
+ text[i] = ch;
+ text += i+1;
+ i = -1;
+ if (x >= ev->x) break;
+ dwmblockssig = ch;
+ }
+ }
+ } else
click = ClkWinTitle;
} else if ((c = wintoclient(ev->window))) {
focus(c);
@@ -627,6 +699,19 @@ configurerequest(XEvent *e)
XSync(dpy, False);
}
+void
+copyvalidchars(char *text, char *rawtext)
+{
+ int i = -1, j = 0;
+
+ while(rawtext[++i]) {
+ if ((unsigned char)rawtext[i] >= ' ') {
+ text[j++] = rawtext[i];
+ }
+ }
+ text[j] = '\0';
+}
+
Monitor *
createmon(void)
{
@@ -638,6 +723,10 @@ 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);
@@ -709,19 +798,19 @@ drawbar(Monitor *m)
}
for (c = m->clients; c; c = c->next) {
- occ |= c->tags;
+ occ |= c->tags == 255 ? 0 : c->tags;
if (c->isurgent)
urg |= c->tags;
}
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
+ /* do not draw vacant tags */
+ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
+ continue;
+
w = TEXTW(tags[i]);
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
- if (occ & 1 << i)
- drw_rect(drw, x + boxs, boxs, boxw, boxw,
- m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
- urg & 1 << i);
x += w;
}
w = blw = TEXTW(m->ltsymbol);
@@ -832,27 +921,16 @@ focusmon(const Arg *arg)
void
focusstack(const Arg *arg)
{
- Client *c = NULL, *i;
+ int i = stackpos(arg);
+ Client *c, *p;
- if (!selmon->sel)
+ if (i < 0 || selmon->sel->isfullscreen)
return;
- if (arg->i > 0) {
- for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
- if (!c)
- for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
- } else {
- for (i = selmon->clients; i != selmon->sel; i = i->next)
- if (ISVISIBLE(i))
- c = i;
- if (!c)
- for (; i; i = i->next)
- if (ISVISIBLE(i))
- c = i;
- }
- if (c) {
- focus(c);
- restack(selmon);
- }
+
+ for(p = NULL, c = selmon->clients; c && (i || !ISVISIBLE(c));
+ i -= ISVISIBLE(c) ? 1 : 0, p = c, c = c->next);
+ focus(c ? c : p);
+ restack(selmon);
}
Atom
@@ -872,6 +950,18 @@ getatomprop(Client *c, Atom prop)
}
int
+getdwmblockspid()
+{
+ char buf[16];
+ FILE *fp = popen("pidof -s dwmblocks", "r");
+ fgets(buf, sizeof(buf), fp);
+ pid_t pid = strtoul(buf, NULL, 10);
+ pclose(fp);
+ dwmblockspid = pid;
+ return pid != 0 ? 0 : -1;
+}
+
+int
getrootptr(int *x, int *y)
{
int di;
@@ -998,6 +1088,49 @@ keypress(XEvent *e)
keys[i].func(&(keys[i].arg));
}
+int
+fake_signal(void)
+{
+ char fsignal[256];
+ char indicator[9] = "fsignal:";
+ char str_sig[50];
+ char param[16];
+ int i, len_str_sig, n, paramn;
+ size_t len_fsignal, len_indicator = strlen(indicator);
+ Arg arg;
+
+ // Get root name property
+ if (gettextprop(root, XA_WM_NAME, fsignal, sizeof(fsignal))) {
+ len_fsignal = strlen(fsignal);
+
+ // Check if this is indeed a fake signal
+ if (len_indicator > len_fsignal ? 0 : strncmp(indicator, fsignal, len_indicator) == 0) {
+ paramn = sscanf(fsignal+len_indicator, "%s%n%s%n", str_sig, &len_str_sig, param, &n);
+
+ if (paramn == 1) arg = (Arg) {0};
+ else if (paramn > 2) return 1;
+ else if (strncmp(param, "i", n - len_str_sig) == 0)
+ sscanf(fsignal + len_indicator + n, "%i", &(arg.i));
+ else if (strncmp(param, "ui", n - len_str_sig) == 0)
+ sscanf(fsignal + len_indicator + n, "%u", &(arg.ui));
+ else if (strncmp(param, "f", n - len_str_sig) == 0)
+ sscanf(fsignal + len_indicator + n, "%f", &(arg.f));
+ else return 1;
+
+ // Check if a signal was found, and if so handle it
+ for (i = 0; i < LENGTH(signals); i++)
+ if (strncmp(str_sig, signals[i].sig, len_str_sig) == 0 && signals[i].func)
+ signals[i].func(&(arg));
+
+ // A fake signal was sent
+ return 1;
+ }
+ }
+
+ // No fake signal was sent, so proceed with update
+ return 0;
+}
+
void
killclient(const Arg *arg)
{
@@ -1015,6 +1148,37 @@ killclient(const Arg *arg)
}
void
+loadxrdb()
+{
+ Display *display;
+ char * resm;
+ XrmDatabase xrdb;
+ char *type;
+ XrmValue value;
+
+ display = XOpenDisplay(NULL);
+
+ if (display != NULL) {
+ resm = XResourceManagerString(display);
+
+ if (resm != NULL) {
+ xrdb = XrmGetStringDatabase(resm);
+
+ if (xrdb != NULL) {
+ XRDB_LOAD_COLOR("dwm.color0", normbordercolor);
+ XRDB_LOAD_COLOR("dwm.color8", selbordercolor);
+ XRDB_LOAD_COLOR("dwm.color0", normbgcolor);
+ XRDB_LOAD_COLOR("dwm.color6", normfgcolor);
+ XRDB_LOAD_COLOR("dwm.color0", selfgcolor);
+ XRDB_LOAD_COLOR("dwm.color14", selbgcolor);
+ }
+ }
+ }
+
+ XCloseDisplay(display);
+}
+
+void
manage(Window w, XWindowAttributes *wa)
{
Client *c, *t = NULL;
@@ -1049,6 +1213,14 @@ manage(Window w, XWindowAttributes *wa)
&& (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
c->bw = borderpx;
+ selmon->tagset[selmon->seltags] &= ~scratchtag;
+ if (!strcmp(c->name, scratchpadname)) {
+ c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag;
+ c->isfloating = True;
+ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
+ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
+ }
+
wc.border_width = c->bw;
XConfigureWindow(dpy, w, CWBorderWidth, &wc);
XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel);
@@ -1103,16 +1275,16 @@ maprequest(XEvent *e)
void
monocle(Monitor *m)
{
- unsigned int n = 0;
- Client *c;
+ unsigned int n = 0;
+ Client *c;
- for (c = m->clients; c; c = c->next)
- if (ISVISIBLE(c))
- n++;
- if (n > 0) /* override layout symbol */
- snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
- for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
- resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
+ for (c = m->clients; c; c = c->next)
+ if (ISVISIBLE(c))
+ n++;
+ if (n > 0) /* override layout symbol */
+ snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
+ for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
+ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
}
void
@@ -1209,17 +1381,41 @@ pop(Client *c)
}
void
+pushstack(const Arg *arg) {
+ int i = stackpos(arg);
+ Client *sel = selmon->sel, *c, *p;
+
+ if(i < 0)
+ return;
+ else if(i == 0) {
+ detach(sel);
+ attach(sel);
+ }
+ else {
+ for(p = NULL, c = selmon->clients; c; p = c, c = c->next)
+ if(!(i -= (ISVISIBLE(c) && c != sel)))
+ break;
+ c = c ? c : p;
+ detach(sel);
+ sel->next = c->next;
+ c->next = sel;
+ }
+ arrange(selmon);
+}
+
+void
propertynotify(XEvent *e)
{
Client *c;
Window trans;
XPropertyEvent *ev = &e->xproperty;
- if ((ev->window == root) && (ev->atom == XA_WM_NAME))
- updatestatus();
- else if (ev->state == PropertyDelete)
+ if ((ev->window == root) && (ev->atom == XA_WM_NAME)) {
+ if (!fake_signal())
+ updatestatus();
+ } else if (ev->state == PropertyDelete) {
return; /* ignore */
- else if ((c = wintoclient(ev->window))) {
+ } else if ((c = wintoclient(ev->window))) {
switch(ev->atom) {
default: break;
case XA_WM_TRANSIENT_FOR:
@@ -1248,6 +1444,7 @@ propertynotify(XEvent *e)
void
quit(const Arg *arg)
{
+ if(arg->i) restart = 1;
running = 0;
}
@@ -1381,6 +1578,11 @@ run(void)
}
void
+runAutostart(void) {
+ system("killall dwmblocks 2>/dev/null ; dwmblocks &");
+}
+
+void
scan(void)
{
unsigned int i, num;
@@ -1497,6 +1699,36 @@ setfullscreen(Client *c, int fullscreen)
}
}
+int
+stackpos(const Arg *arg) {
+ int n, i;
+ Client *c, *l;
+
+ if(!selmon->clients)
+ return -1;
+
+ if(arg->i == PREVSEL) {
+ for(l = selmon->stack; l && (!ISVISIBLE(l) || l == selmon->sel); l = l->snext);
+ if(!l)
+ return -1;
+ for(i = 0, c = selmon->clients; c != l; i += ISVISIBLE(c) ? 1 : 0, c = c->next);
+ return i;
+ }
+ else if(ISINC(arg->i)) {
+ if(!selmon->sel)
+ return -1;
+ for(i = 0, c = selmon->clients; c != selmon->sel; i += ISVISIBLE(c) ? 1 : 0, c = c->next);
+ for(n = i; c; n += ISVISIBLE(c) ? 1 : 0, c = c->next);
+ return MOD(i + GETINC(arg->i), n);
+ }
+ else if(arg->i < 0) {
+ for(i = 0, c = selmon->clients; c; i += ISVISIBLE(c) ? 1 : 0, c = c->next);
+ return MAX(i + arg->i, 0);
+ }
+ else
+ return arg->i;
+}
+
void
setlayout(const Arg *arg)
{
@@ -1536,6 +1768,9 @@ setup(void)
/* clean up any zombies immediately */
sigchld(0);
+ signal(SIGHUP, sighup);
+ signal(SIGTERM, sigterm);
+
/* init screen */
screen = DefaultScreen(dpy);
sw = DisplayWidth(dpy, screen);
@@ -1637,10 +1872,42 @@ sigchld(int unused)
}
void
+sighup(int unused)
+{
+ Arg a = {.i = 1};
+ quit(&a);
+}
+
+void
+sigterm(int unused)
+{
+ Arg a = {.i = 0};
+ quit(&a);
+}
+
+void
+sigdwmblocks(const Arg *arg)
+{
+ union sigval sv;
+ sv.sival_int = 0 | (dwmblockssig << 8) | arg->i;
+ if (!dwmblockspid)
+ if (getdwmblockspid() == -1)
+ return;
+
+ if (sigqueue(dwmblockspid, SIGUSR1, sv) == -1) {
+ if (errno == ESRCH) {
+ if (!getdwmblockspid())
+ sigqueue(dwmblockspid, SIGUSR1, sv);
+ }
+ }
+}
+
+void
spawn(const Arg *arg)
{
if (arg->v == dmenucmd)
dmenumon[0] = '0' + selmon->num;
+ selmon->tagset[selmon->seltags] &= ~scratchtag;
if (fork() == 0) {
if (dpy)
close(ConnectionNumber(dpy));
@@ -1671,32 +1938,6 @@ tagmon(const Arg *arg)
}
void
-tile(Monitor *m)
-{
- unsigned int i, n, h, mw, my, ty;
- Client *c;
-
- for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
- if (n == 0)
- return;
-
- 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);
- my += HEIGHT(c);
- } 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);
- ty += HEIGHT(c);
- }
-}
-
-void
togglebar(const Arg *arg)
{
selmon->showbar = !selmon->showbar;
@@ -1720,6 +1961,44 @@ togglefloating(const Arg *arg)
}
void
+togglescratch(const Arg *arg)
+{
+ Client *c;
+ unsigned int found = 0;
+
+ for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
+ if (found) {
+ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
+ if (newtagset) {
+ selmon->tagset[selmon->seltags] = newtagset;
+ focus(NULL);
+ arrange(selmon);
+ }
+ if (ISVISIBLE(c)) {
+ focus(c);
+ restack(selmon);
+ }
+ } else
+ spawn(arg);
+}
+
+void
+togglefullscr(const Arg *arg)
+{
+ if(selmon->sel)
+ setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
+}
+
+void
+togglesticky(const Arg *arg)
+{
+ if (!selmon->sel)
+ return;
+ selmon->sel->issticky = !selmon->sel->issticky;
+ arrange(selmon);
+}
+
+void
toggletag(const Arg *arg)
{
unsigned int newtags;
@@ -1987,8 +2266,10 @@ updatesizehints(Client *c)
void
updatestatus(void)
{
- if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
+ if (!gettextprop(root, XA_WM_NAME, rawstext, sizeof(rawstext)))
strcpy(stext, "dwm-"VERSION);
+ else
+ copyvalidchars(stext, rawstext);
drawbar(selmon);
}
@@ -2111,6 +2392,17 @@ xerrorstart(Display *dpy, XErrorEvent *ee)
}
void
+xrdb(const Arg *arg)
+{
+ loadxrdb();
+ int i;
+ for (i = 0; i < LENGTH(colors); i++)
+ scheme[i] = drw_scm_create(drw, colors[i], 3);
+ focus(NULL);
+ arrange(NULL);
+}
+
+void
zoom(const Arg *arg)
{
Client *c = selmon->sel;
@@ -2136,13 +2428,17 @@ main(int argc, char *argv[])
if (!(dpy = XOpenDisplay(NULL)))
die("dwm: cannot open display");
checkotherwm();
+ XrmInitialize();
+ loadxrdb();
setup();
#ifdef __OpenBSD__
if (pledge("stdio rpath proc exec", NULL) == -1)
die("pledge");
#endif /* __OpenBSD__ */
scan();
+ runAutostart();
run();
+ if(restart) execvp(argv[0], argv);
cleanup();
XCloseDisplay(dpy);
return EXIT_SUCCESS;
diff --git a/dwmc b/dwmc
new file mode 100755
index 0000000..a724911
--- /dev/null
+++ b/dwmc
@@ -0,0 +1,40 @@
+#!/usr/bin/env sh
+
+signal() {
+ xsetroot -name "fsignal:$*"
+}
+
+case $# in
+1)
+ case $1 in
+ setlayout | view | viewall | togglebar | togglefloating | zoom | killclient | quit | xrdb)
+ signal $1
+ ;;
+ *)
+ echo "Unknown command or missing one argument."
+ exit 1
+ ;;
+ esac
+ ;;
+2)
+ case $1 in
+ view)
+ signal $1 ui $2
+ ;;
+ viewex | toggleviewex | tagex | toggletagex | setlayoutex | focusstack | incnmaster | focusmon | tagmon)
+ signal $1 i $2
+ ;;
+ setmfact)
+ signal $1 f $2
+ ;;
+ *)
+ echo "Unknown command or one too many arguments."
+ exit 1
+ ;;
+ esac
+ ;;
+*)
+ echo "Too many arguments."
+ exit 1
+ ;;
+esac
diff --git a/larbs.mom b/larbs.mom
new file mode 100644
index 0000000..4e786b0
--- /dev/null
+++ b/larbs.mom
@@ -0,0 +1,346 @@
+.de LI
+.LIST
+.SHIFT_LIST 10p
+..
+.PARA_SPACE 1m
+.TITLE "\s+(10A Friendly Guide to LARBS!\s0"
+.AUTHOR "\s+5Luke Smith\s0"
+.DOCTYPE DEFAULT
+.COPYSTYLE FINAL
+.PRINTSTYLE TYPESET
+.PT_SIZE 12
+.START
+Use vim keys (\f(CWh/j/k/l\fP) to navigate this document.
+Pressing \f(CWs\fP will fit it to window width (\f(CWa\fP to revert).
+\f(CWK\fP and \f(CWJ\fP zoom in and out.
+\f(CWSuper+f\fP to toggle fullscreen.
+\f(CWq\fP to quit.
+(These are general binds set for \fBzathura\fP, the pdf reader.)
+.LI
+.ITEM
+\f(CWMod+F1\fP will show this document at any time.
+.ITEM
+By \f(CWMod\fP, I mean the Super Key, usually known as "the Windows Key."
+.LIST OFF
+.PP
+FAQs are at the end of this document.
+.HEADING 1 "Welcome!"
+.HEADING 2 "Basic goals and principles of this system:"
+.LI
+.ITEM
+\fBNaturalness\fP \(en
+Remove the border between mind and matter:
+everything important should be as few keypresses as possible away from you,
+and you shouldn't have to think about what you're doing.
+Immersion.
+.ITEM
+\fBEconomy\fP \(en
+Programs should be simple and light on system resources and highly extensible.
+Because of this, many are terminal or small ncurses programs that have all the magic inside of them.
+.ITEM
+\fBKeyboard/vim-centrality\fP \(en
+All terminal programs (and other programs) use vim keys when possible.
+Your hands never need leave the home row or thereabout.
+.ITEM
+\fBDecentralization\fP \(en
+This system is a web of small, modifiable and replaceable programs that users can easily customize.
+.LIST OFF
+.HEADING 2 "General keyboard changes"
+.LI
+.ITEM
+Capslock is a useless key in high quality space.
+It's now remapped.
+If you press it alone, it will function as escape, making vimcraft much more natural,
+but you can also hold it down and it will act as another Windows/super/mod key.
+.ITEM
+The menu button (usually between the right Alt and Ctrl) is an alternative Super/Mod button.
+This is to make one-handing on laptops easier.
+.LIST OFF
+.PP
+If you'd like to change any of these keyboard changes, you need only open and change the \f(CWremaps\fP script.
+All custom scripts in LARBS are located in \f(CW~/.local/bin/\fP.
+Actually, this should go without saying, but \fIeverything\fP here can easily be changed.
+Below in this document, there is information about where to change programs/components.
+.PP
+Additionally, while this isn't a part of the desktop environment, the default editing mode in the shell is using vi bindings.
+If you want to learn more of this, run \f(CWMod+Shift+E\fP and type and select the option for "vi mode in shell".
+This setting can be changed if you don't like it by deleting or commenting out the contents of \f(CW~/.config/inputrc\fP.
+.HEADING 2 "The Status Bar"
+.PP
+To the left, you'll see the numbers of your current workspace/tag(s).
+On the right, you'll see various system status notifiers, the date, volume, even music and local weather if possible, etc.
+Each module on the right of the status bar is a script located in \f(CW~/.local/bin/statusbar/\fP.
+You can see what they do and modify them from there.
+I'm sure you can figure it out.
+You can also right click on the module to see what it does.
+.PP
+The program dwmblocks is what is run to generate the statusbar from those scripts.
+You can edit its config/source code in \f(CW~/.local/src/dwmblocks/\fP to tell it what scripts/commands you want it to display.
+.HEADING 2 "Deeper Tutorials"
+.PP
+Press \f(CWmod+shift+e\fP at any time to get a menu of programs to watch videos about streaming directly from YouTube.
+You can also check the config files for programs which detail a lot of the specific bindings.
+.HEADING 1 "Key Bindings"
+.PP
+The window manager dwm abstractly orders all of your windows into a stack from most important to least based on when you last manipulated it.
+dwm is an easy to use window manager, but you should understand that it makes use of that stack layout.
+If you're not familiar, I recommend you press \f(CWMod+Shift+E\fP and select the "dwm" option to watch my brief tutorial (note that the bindings I discuss in the video are the default dwm binds, which are different (inferior) to those here).
+.PP
+Notice also the case sensitivity of the shortcuts\c
+.FOOTNOTE
+To type capital letters, hold down the \f(CWShift\fP key\(emthat might sound like an obvious and condescending thing to tell you, but there have literally been multiple people (Boomers) who have emailed me asking how to type a capital letter since caps lock isn't enabled.
+.FOOTNOTE OFF
+ , Be sure you play around with these. Be flexible with the basic commands and the system will grow on you quick.
+.LI
+.ITEM
+\f(CWMod+Enter\fP \(en Spawn terminal (the default terminal is \f(CWst\fP; run \f(CWman st\fP for more.)
+.ITEM
+\f(CWMod+q\fP \(en Close window
+.ITEM
+\f(CWMod+d\fP \(en dmenu (For running commands or programs without shortcuts)
+.ITEM
+\f(CWMod+j/k\fP \(en Cycle thru windows by their stack order
+.ITEM
+\f(CWMod+Space\fP \(en Make selected window the master (or switch master with 2nd)
+.ITEM
+\f(CWMod+h/l\fP \(en Change width of master window
+.ITEM
+\f(CWMod+z/Z\fP \(en Increase/decrease gaps
+.ITEM
+\f(CWMod+D\fP \(en Toggle gaps
+.ITEM
+\f(CWMod+Shift+Space\fP \(en Make a window float (move and resize with \f(CWMod+\fPleft/right click).
+.ITEM
+\f(CWMod+b\fP \(en Toggle status bar
+.ITEM
+\f(CWMod+B\fP \(en Toggle window float in bottom left corner (good for video watched intermittently)
+.ITEM
+\f(CWMod+N\fP \(en Same as above, but for the bottom right corner.
+.LIST OFF
+.HEADING 2 "Window layouts"
+.LI
+.ITEM
+\f(CWMod+t\fP \(en Tiling mode (active by default)
+.ITEM
+\f(CWMod+T\fP \(en Bottom stack mode (just like tiling, but master is on top)
+.ITEM
+\f(CWMod+f\fP \(en Fullscreen mode
+.ITEM
+\f(CWMod+F\fP \(en Floating (AKA normie) mode
+.ITEM
+\f(CWMod+y\fP \(en Fibbonacci spiral mode
+.ITEM
+\f(CWMod+Y\fP \(en Dwindle mode (similar to Fibonacci)
+.ITEM
+\f(CWMod+u\fP \(en Master on left, other windows in monocle mode
+.ITEM
+\f(CWMod+U\fP \(en Monocle mode (all windows fullscreen and cycle through)
+.ITEM
+\f(CWMod+i\fP \(en Center the master window
+.ITEM
+\f(CWMod+I\fP \(en Center and float the master window
+.ITEM
+\f(CWMod+o/O\fP \(en Increase/decrease the number of master windows
+.LIST OFF
+.HEADING 2 "Basic Programs"
+.LI
+.ITEM
+\f(CWMod+r\fP \(en lf (file browser/manager)
+.ITEM
+\f(CWMod+e\fP \(en neomutt (email) \(en Must be first configured by running \f(CWmw add\fP.
+.ITEM
+\f(CWMod+m\fP \(en ncmpcpp (music player)
+.ITEM
+\f(CWMod+w\fP \(en Web browser (Brave)
+.ITEM
+\f(CWMod+n\fP \(en newsboat (RSS feed reader)
+.ITEM
+\f(CWMod+a\fP \(en pulsemixer (audio system control)
+.ITEM
+\f(CWMod+W\fP \(en nmtui (for connecting to wireless internet)
+.ITEM
+\f(CWMod+v\fP \(en vimwiki (for notes)
+.ITEM
+\f(CWMod+Shift+Enter\fP \(en Show/hide dropdown terminal
+.LIST OFF
+.HEADING 2 "System"
+.LI
+.ITEM
+\f(CWMod+x\fP \(en Lock screen (Enter password to return)
+.ITEM
+\f(CWMod+X\fP \(en Shutdown (will ask to confirm)
+.ITEM
+\f(CWMod+Shift+Backspace\fP \(en Reboot (will ask to confirm)
+.ITEM
+\f(CWMod+Shift+Escape\fP \(en Exit the graphical environment (will ask to confirm)
+.ITEM
+\f(CWMod+V\fP \(en Toggle xcompmgr (to remove transparency and window effects)
+.ITEM
+\f(CWMod+F1\fP \(en Shows this document
+.ITEM
+\f(CWMod+F2\fP \(en Restart dwm (makes active any changes you've made to dwm)
+.ITEM
+\f(CWMod+F3\fP \(en Select screen/display to use
+.ITEM
+\f(CWMod+F4\fP \(en Hibernate (will ask to confirm)
+.ITEM
+\f(CWMod+F5\fP \(en Update dwm's colorscheme if you have changed Xresources
+.ITEM
+\f(CWMod+F6\fP \(en Transmission torrent client (not installed by default)
+.ITEM
+\f(CWMod+F7\fP \(en Toggle on/off transmission client via dmenu
+.ITEM
+\f(CWMod+F8\fP \(en Check mail, if mutt-wizard is configured. (Run \f(CWmw add\fP to set up.)
+.ITEM
+\f(CWMod+F9\fP \(en Mount a USB drive/hard drive or Android
+.ITEM
+\f(CWMod+F10\fP \(en Unmount a non-essential drive or Android
+.ITEM
+\f(CWMod+`\fP \(en Select an emoji to copy to clipboard
+.ITEM
+\f(CWMod+Insert\fP \(en Show contents of clipboard/primary selection
+.LIST OFF
+.HEADING 2 "Audio"
+.PP
+I use ncmpcpp as a music player, which is a front end for mpd.
+.LI
+.ITEM
+\f(CWMod+m\fP \(en ncmpcpp, the music player
+.ITEM
+\f(CWMod+.\fP \(en Next track
+.ITEM
+\f(CWMod+,\fP \(en Previous track
+.ITEM
+\f(CWMod+<\fP \(en Restart track
+.ITEM
+\f(CWMod+>\fP \(en Toggle playlist looping
+.ITEM
+\f(CWMod+p\fP \(en Pause
+.ITEM
+\f(CWMod+M\fP \(en Mute all audio
+.ITEM
+\f(CWMod+-\fP \(en Decrease volume (holding shift increases amount)
+.ITEM
+\f(CWMod++\fP \(en Increase volume (holding shift increases amount)
+.ITEM
+\f(CWMod+[\fP \(en Back 10 seconds (holding shift increases amount)
+.ITEM
+\f(CWMod+]\fP \(en Forward 10 seconds (holding shift increases amount)
+.ITEM
+\f(CWMod+a\fP \(en pulsemixer (general volume sink/source control)
+.LIST OFF
+.HEADING 2 "Tags/Workspaces"
+.PP
+There are nine tags, active tags are highlighted in the top left.
+.LI
+.ITEM
+\f(CWMod+(Number)\fP \(en Go to that number tag
+.ITEM
+\f(CWMod+Shift+(Number)\fP \(en Send window to that tag
+.ITEM
+\f(CWMod+Tab\fP \(en Go to previous tag (may also use \f(CW\\\fP for Tab)
+.ITEM
+\f(CWMod+g\fP \(en Go to left tag
+.ITEM
+\f(CWMod+;\fP \(en Go to right tag
+.ITEM
+\f(CWMod+Left\fP \(en Move to workspace to the left
+.ITEM
+\f(CWMod+Right\fP \(en Move to workspace to the right
+.LIST OFF
+.HEADING 2 "Recording"
+.PP
+I use maim and ffmpeg to make different recordings of the desktop and audio.
+All of these recording shortcuts will output into \f(CW~\fP, and will not overwrite
+previous recordings as their names are based on their exact times.
+.LI
+.ITEM
+\f(CWPrintScreen\fP \(en Take a screenshot
+.ITEM
+\f(CWShift+PrintScreen\fP \(en Select area to screenshot
+.ITEM
+\f(CWMod+PrintScreen\fP \(en Opens dmenu menu to select kind of audio/video recording
+.ITEM
+\f(CWMod+Delete\fP \(en Kills any recording started in the above way.
+.ITEM
+\f(CWMod+Shift+c\fP \(en Toggles a webcam in the bottom right for screencasting.
+.ITEM
+\f(CWMod+ScrollLock\fP \(en Toggle screenkey (if installed) to show keypresses
+.LIST OFF
+.HEADING 2 "Other buttons"
+.PP
+I've mapped those extra buttons that some keyboards have (play and pause
+buttons, screen brightness, email, web browsing buttons, etc.) to what you
+would expect.
+.HEADING 1 "Configuration"
+.PP
+Dotfiles/settings files are located in \f(CW~/.config/\fP, note that dotfiles to programs not included in LARBS are there as well by requests of users. I do not necessarily maintain all these dotfiles, but they remain as legacy.
+.PP
+Suckless programs, dwm (the window manager), st (the terminal) and dmenu among others do not have traditional config files, but have their source code location in \f(CW~/.local/src/\fP.
+There you can modify their \f(CWconfig.h\fP files, then \f(CWsudo make install\fP to reinstall.
+(You'll have to restart the program to see its effects obviously.)
+.HEADING 1 "Frequently Asked Questions (FAQs)"
+.HEADING 2 "My keyboard isn't working as expected!"
+.PP
+As mentioned above, LARBS makes some keyboard changes with the \f(CWremaps\fP script.
+These settings may override your preferred settings, so you should open this file and comment out troublesome lines if you have issues.
+.HEADING 2 "My audio isn't working!"
+.PP
+On fresh install, the Linux audio system often mutes outputs.
+You may also need to set your preferred default output sink which you can do by the command line, or by selecting one with \f(CWpulsemixer\fP (\f(CWmod+a\fP).
+.HEADING 2 "How do I copy and paste?"
+.PP
+Copying and pasting is always program-specific on any system.
+In most graphical programs, copy and paste will be the same as they are on Windows: \f(CWctrl-c\fP and \f(CWctrl-v\fP.
+In the Linux terminal, those binds have other more important purposes, so you can run \f(CWman st\fP to see how to copy and paste in my terminal build.
+.PP
+Additionally, I've set vim to use the clipboard as the default buffer, which means when you yank or delete something in vim, it will be in your system clipboard as well, so you can \f(CWctrl-v\fP it into your browser instance, etc. You can also paste material copied from other programs into vim with the typical vim bindings.
+.HEADING 2 "How do I change the background/wallpaper?"
+.PP
+The system will always read the file \f(CW~/.config/wall.png\fP as the wallpaper.
+The script \f(CWsetbg\fP, if run on an image will set it as the persistent background.
+When using the file manager, you can simply hover over an image name and type \f(CWbg\fP and this will run \f(CWsetbg\fP.
+.HEADING 2 "How I change the colorscheme?"
+.PP
+LARBS no longer deploys Xresource by default, but check \f(CW~/.config/Xresources\fP for a list of color schemes you can activate or add your own. When you save the file, vim will automatically update the colorscheme. If you'd like these colors activated by default on login, there is a line in \f(CW~/.config/xprofile\fP you can uncomment to allow that.
+.PP
+Or, if you want to use \f(CWwal\fP to automatically generate colorschemes from your wallpapers, just install it and \f(CWsetbg\fP will automatically detect and run it on startup and wallpaper change.
+.HEADING 2 "How do I set up my email?"
+.PP
+LARBS comes with mutt-wizard, which gives the ability to receive and send all your email and keep an offline store of it all in your terminal, without the need for browser.
+You can add email accounts by running \f(CWmw add\fP.
+.PP
+Once you have successfully added your email address(es), you can open your mail with \f(CWneomutt\fP which is also bound to \f(CWMod+e\fP.
+You can sync your mail by pressing \f(CWMod+F8\fP and you can set a cronjob to sync mail every several minutes by running \f(CWmw cron\fP.
+.PP
+You may also want to install \f(CWpam-gnupg-git\fP, which can be set up to automatically unlock your GPG key on login, which will allow you avoid having put in a password to sync and send, all while keeping your password safe and encypted on your machine.
+.HEADING 2 "How do I set up my music?"
+.PP
+By default, mpd, the music daemon assumes that \f(CW~/Music\fP is your music directory.
+This can be changed in \f(CW~/.config/mpd/mpd.conf\fP.
+When you add music to your music folder, you may have to run \f(CWmpc up\fP in the terminal to update the database.
+mpd is controlled by ncmpcpp, which is accessible by \f(CWMod+m\fP.
+.HEADING 2 "How do I update LARBS?"
+.PP
+LARBS is deployed as a git repository in your home directory.
+You can use it as such to fetch, diff and merge changes from the remote repository.
+If you don't want to do that or don't know how to use git, you can actually just rerun the script (as root) and reinstall LARBS and it will automatically update an existing install if you select the same username.
+This will overwrite the original config files though, including changes you made for them, but this is an easier brute force approach that will also install any new dependencies.
+.HEADING 1 "Contact"
+.LI
+.ITEM
+.PDF_WWW_LINK "mailto:luke@lukesmith.xyz" "luke@lukesmith.xyz"
+\(en For questions!
+.ITEM
+.PDF_WWW_LINK "http://lukesmith.xyz" "https://lukesmith.xyz"
+\(en For stalking!
+.ITEM
+.PDF_WWW_LINK "https://lukesmith.xyz/donate" "https://lukesmith.xyz/donate"
+\(en To incentivize more development of LARBS!
+.ITEM
+.PDF_WWW_LINK "https://github.com/LukeSmithxyz" "My Github Page"
+\(en For the code behind it!
+.ITEM
+.PDF_WWW_LINK "http://lukesmith.xyz/rss.xml" "RSS"
+\(en For updates!
+.LIST OFF
diff --git a/shiftview.c b/shiftview.c
new file mode 100644
index 0000000..b592a67
--- /dev/null
+++ b/shiftview.c
@@ -0,0 +1,36 @@
+/** Function to shift the current view to the left/right
+ *
+ * @param: "arg->i" stores the number of tags to shift right (positive value)
+ * or left (negative value)
+ */
+void
+shiftview(const Arg *arg)
+{
+ Arg a;
+ Client *c;
+ unsigned visible = 0;
+ int i = arg->i;
+ int count = 0;
+ int nextseltags, curseltags = selmon->tagset[selmon->seltags];
+
+ do {
+ if(i > 0) // left circular shift
+ nextseltags = (curseltags << i) | (curseltags >> (LENGTH(tags) - i));
+
+ else // right circular shift
+ nextseltags = curseltags >> (- i) | (curseltags << (LENGTH(tags) + i));
+
+ // Check if tag is visible
+ for (c = selmon->clients; c && !visible; c = c->next)
+ if (nextseltags & c->tags) {
+ visible = 1;
+ break;
+ }
+ i += arg->i;
+ } while (!visible && ++count < 10);
+
+ if (count < 10) {
+ a.i = nextseltags;
+ view(&a);
+ }
+}
diff --git a/vanitygaps.c b/vanitygaps.c
new file mode 100644
index 0000000..31719be
--- /dev/null
+++ b/vanitygaps.c
@@ -0,0 +1,481 @@
+/* Key binding functions */
+static void defaultgaps(const Arg *arg);
+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);
+/* Layouts */
+static void bstack(Monitor *m);
+static void centeredmaster(Monitor *m);
+static void centeredfloatingmaster(Monitor *m);
+static void deck(Monitor *m);
+static void dwindle(Monitor *m);
+static void fibonacci(Monitor *m, int s);
+static void spiral(Monitor *m);
+static void tile(Monitor *m);
+/* Internals */
+static void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc);
+static void setgaps(int oh, int ov, int ih, int iv);
+
+/* Settings */
+static int enablegaps = 1;
+
+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(NULL);
+}
+
+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
+ );
+}
+
+static 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
+getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc )
+{
+ unsigned int n, oe = enablegaps, ie = enablegaps;
+ Client *c;
+
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ if (smartgaps && n == 1) {
+ oe = 0; // outer gaps disabled when only one client
+ }
+
+ *oh = m->gappoh*oe; // outer horizontal gap
+ *ov = m->gappov*oe; // outer vertical gap
+ *ih = m->gappih*ie; // inner horizontal gap
+ *iv = m->gappiv*ie; // inner vertical gap
+ *nc = n; // number of clients
+}
+
+/***
+ * Layouts
+ */
+
+/*
+ * Bottomstack layout + gaps
+ * https://dwm.suckless.org/patches/bottomstack/
+ */
+void
+bstack(Monitor *m)
+{
+ unsigned int i, n;
+ int mx = 0, my = 0, mh = 0, mw = 0;
+ int sx = 0, sy = 0, sh = 0, sw = 0;
+ int oh, ov, ih, iv;
+ Client *c;
+
+ getgaps(m, &oh, &ov, &ih, &iv, &n);
+
+ if (n == 0)
+ return;
+
+ sx = mx = m->wx + ov;
+ sy = my = m->wy + oh;
+ sh = mh = m->wh - 2*oh;
+ sw = mw = m->ww - 2*ov - iv * (MIN(n, m->nmaster) - 1);
+
+ if (m->nmaster && n > m->nmaster) {
+ sh = (mh - ih) * (1 - m->mfact);
+ mh = (mh - ih) * m->mfact;
+ sy = my + mh + ih;
+ sw = m->ww - 2*ov - iv * (n - m->nmaster - 1);
+ }
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < m->nmaster) {
+ resize(c, mx, my, mw / MIN(n, m->nmaster) - (2*c->bw), mh - (2*c->bw), 0);
+ mx += WIDTH(c) + iv;
+ } else {
+ resize(c, sx, sy, sw / (n - MIN(n, m->nmaster)) - (2*c->bw), sh - (2*c->bw), 0);
+ sx += WIDTH(c) + iv;
+ }
+ }
+}
+
+/*
+ * Centred master layout + gaps
+ * https://dwm.suckless.org/patches/centeredmaster/
+ */
+void
+centeredmaster(Monitor *m)
+{
+ unsigned int i, n;
+ int mx = 0, my = 0, mh = 0, mw = 0;
+ int lx = 0, ly = 0, lw = 0, lh = 0;
+ int rx = 0, ry = 0, rw = 0, rh = 0;
+ int oh, ov, ih, iv;
+ int mn = 0, ln = 0, rn = 0; // number of clients in master, left and right area
+ Client *c;
+
+ getgaps(m, &oh, &ov, &ih, &iv, &n);
+
+ if (n == 0)
+ return;
+
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
+ if (!m->nmaster || n < m->nmaster)
+ mn += 1;
+ else if ((n - m->nmaster) % 2)
+ ln += 1; // total factor of left hand stacke area
+ else
+ rn += 1; // total factor of right hand stack area
+ }
+
+ /* initialize areas */
+ mx = m->wx + ov;
+ my = m->wy + oh;
+ mh = m->wh - 2*oh - ih * ((!m->nmaster ? n : MIN(n, m->nmaster)) - 1);
+ mw = m->ww - 2*ov;
+ lh = m->wh - 2*oh - ih * (((n - m->nmaster) / 2) - 1);
+ rh = m->wh - 2*oh - ih * (((n - m->nmaster) / 2) - ((n - m->nmaster) % 2 ? 0 : 1));
+
+ if (m->nmaster && n > m->nmaster) {
+ /* go mfact box in the center if more than nmaster clients */
+ if (n - m->nmaster > 1) {
+ /* ||<-S->|<---M--->|<-S->|| */
+ mw = (m->ww - 2*ov - 2*iv) * m->mfact;
+ lw = (m->ww - mw - 2*ov - 2*iv) / 2;
+ mx += lw + iv;
+ } else {
+ /* ||<---M--->|<-S->|| */
+ mw = (mw - iv) * m->mfact;
+ lw = m->ww - mw - iv - 2*ov;
+ }
+ rw = lw;
+ lx = m->wx + ov;
+ ly = m->wy + oh;
+ rx = mx + mw + iv;
+ ry = m->wy + oh;
+ }
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (!m->nmaster || i < m->nmaster) {
+ /* nmaster clients are stacked vertically, in the center of the screen */
+ resize(c, mx, my, mw - (2*c->bw), mh / mn - (2*c->bw), 0);
+ my += HEIGHT(c) + ih;
+ } else {
+ /* stack clients are stacked vertically */
+ if ((i - m->nmaster) % 2 ) {
+ resize(c, lx, ly, lw - (2*c->bw), lh / ln - (2*c->bw), 0);
+ ly += HEIGHT(c) + ih;
+ } else {
+ resize(c, rx, ry, rw - (2*c->bw), rh / rn - (2*c->bw), 0);
+ ry += HEIGHT(c) + ih;
+ }
+ }
+ }
+}
+
+void
+centeredfloatingmaster(Monitor *m)
+{
+ unsigned int i, n;
+ float mivf;
+ int mx = 0, my = 0, mh = 0, mw = 0;
+ int sx = 0, sy = 0, sh = 0, sw = 0;
+ int oh, ov, ih, iv;
+ Client *c;
+
+ getgaps(m, &oh, &ov, &ih, &iv, &n);
+
+ if (n == 0)
+ return;
+
+ mivf = 0.8; // master inner vertical gap factor
+
+ sx = mx = m->wx + ov;
+ sy = my = m->wy + oh;
+ sh = mh = m->wh - 2*oh;
+ sw = mw = m->ww - 2*ov - iv*(n - 1);
+
+ if (m->nmaster && n > m->nmaster) {
+ /* go mfact box in the center if more than nmaster clients */
+ if (m->ww > m->wh) {
+ mw = m->ww * m->mfact - iv*mivf*(MIN(n, m->nmaster) - 1);
+ mh = m->wh * 0.9;
+ } else {
+ mw = m->ww * 0.9 - iv*mivf*(MIN(n, m->nmaster) - 1);
+ mh = m->wh * m->mfact;
+ }
+ mx = m->wx + (m->ww - mw) / 2;
+ my = m->wy + (m->wh - mh - 2*oh) / 2;
+
+ sx = m->wx + ov;
+ sy = m->wy + oh;
+ sh = m->wh - 2*oh;
+ sw = m->ww - 2*ov - iv*(n - m->nmaster - 1);
+ }
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < m->nmaster) {
+ /* nmaster clients are stacked horizontally, in the center of the screen */
+ resize(c, mx, my, mw / MIN(n, m->nmaster) - (2*c->bw), mh - (2*c->bw), 0);
+ mx += WIDTH(c) + iv*mivf;
+ focus(c);
+ } else {
+ /* stack clients are stacked horizontally */
+ resize(c, sx, sy, sw / (n - MIN(n, m->nmaster)) - (2*c->bw), sh - (2*c->bw), 0);
+ sx += WIDTH(c) + iv;
+ }
+ }
+ restack(m);
+}
+
+/*
+ * Deck layout + gaps
+ * https://dwm.suckless.org/patches/deck/
+ */
+void
+deck(Monitor *m)
+{
+ unsigned int i, n;
+ int mx = 0, my = 0, mh = 0, mw = 0;
+ int sx = 0, sy = 0, sh = 0, sw = 0;
+ int oh, ov, ih, iv;
+ Client *c;
+
+ getgaps(m, &oh, &ov, &ih, &iv, &n);
+
+ if (n == 0)
+ return;
+
+ sx = mx = m->wx + ov;
+ sy = my = m->wy + oh;
+ sh = mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1);
+ sw = mw = m->ww - 2*ov;
+
+ if (m->nmaster && n > m->nmaster) {
+ sw = (mw - iv) * (1 - m->mfact);
+ mw = (mw - iv) * m->mfact;
+ sx = mx + mw + iv;
+ sh = m->wh - 2*oh;
+ }
+
+ if (n - m->nmaster > 0) /* override layout symbol */
+ snprintf(m->ltsymbol, sizeof m->ltsymbol, "D %d", n - m->nmaster);
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ if (i < m->nmaster) {
+ resize(c, mx, my, mw - (2*c->bw), mh / MIN(n, m->nmaster) - (2*c->bw), 0);
+ my += HEIGHT(c) + ih;
+ } else {
+ resize(c, sx, sy, sw - (2*c->bw), sh - (2*c->bw), 0);
+ }
+}
+
+/*
+ * Fibonacci layout + gaps
+ * https://dwm.suckless.org/patches/fibonacci/
+ */
+void
+fibonacci(Monitor *m, int s)
+{
+ unsigned int i, n;
+ int nx, ny, nw, nh;
+ int oh, ov, ih, iv;
+ Client *c;
+
+ getgaps(m, &oh, &ov, &ih, &iv, &n);
+
+ if (n == 0)
+ return;
+
+ nx = m->wx + ov;
+ ny = oh;
+ nw = m->ww - 2*ov;
+ nh = m->wh - 2*oh;
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
+ if ((i % 2 && nh / 2 > 2*c->bw)
+ || (!(i % 2) && nw / 2 > 2*c->bw)) {
+ if (i < n - 1) {
+ if (i % 2)
+ nh = (nh - ih) / 2;
+ else
+ nw = (nw - iv) / 2;
+
+ if ((i % 4) == 2 && !s)
+ nx += nw + iv;
+ else if ((i % 4) == 3 && !s)
+ ny += nh + ih;
+ }
+ if ((i % 4) == 0) {
+ if (s)
+ ny += nh + ih;
+ else
+ ny -= nh + ih;
+ }
+ else if ((i % 4) == 1)
+ nx += nw + iv;
+ else if ((i % 4) == 2)
+ ny += nh + ih;
+ else if ((i % 4) == 3) {
+ if (s)
+ nx += nw + iv;
+ else
+ nx -= nw + iv;
+ }
+ if (i == 0) {
+ if (n != 1)
+ nw = (m->ww - 2*ov - iv) * m->mfact;
+ ny = m->wy + oh;
+ }
+ else if (i == 1)
+ nw = m->ww - nw - iv - 2*ov;
+ i++;
+ }
+
+ resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False);
+ }
+}
+
+void
+dwindle(Monitor *m)
+{
+ fibonacci(m, 1);
+}
+
+void
+spiral(Monitor *m)
+{
+ fibonacci(m, 0);
+}
+
+/*
+ * Default tile layout + gaps
+ */
+void
+tile(Monitor *m)
+{
+ unsigned int i, n;
+ int mx = 0, my = 0, mh = 0, mw = 0;
+ int sx = 0, sy = 0, sh = 0, sw = 0;
+ int oh, ov, ih, iv;
+ Client *c;
+
+ getgaps(m, &oh, &ov, &ih, &iv, &n);
+
+ if (n == 0)
+ return;
+
+ sx = mx = m->wx + ov;
+ sy = my = m->wy + oh;
+ sh = mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1);
+ sw = mw = m->ww - 2*ov;
+
+ if (m->nmaster && n > m->nmaster) {
+ sw = (mw - iv) * (1 - m->mfact);
+ mw = (mw - iv) * m->mfact;
+ sx = mx + mw + iv;
+ sh = m->wh - 2*oh - ih * (n - m->nmaster - 1);
+ }
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ if (i < m->nmaster) {
+ resize(c, mx, my, mw - (2*c->bw), mh / MIN(n, m->nmaster) - (2*c->bw), 0);
+ my += HEIGHT(c) + ih;
+ } else {
+ resize(c, sx, sy, sw - (2*c->bw), sh / (n - MIN(n, m->nmaster)) - (2*c->bw), 0);
+ sy += HEIGHT(c) + ih;
+ }
+}