Skip to content

Instantly share code, notes, and snippets.

@pziecina
Last active February 22, 2024 05:29
Show Gist options
  • Save pziecina/4745717 to your computer and use it in GitHub Desktop.
Save pziecina/4745717 to your computer and use it in GitHub Desktop.
dwm configuration

dwm config

Install required packages:

apt-get install libxinerama-dev libx11-dev

Customization of dwm, which base code of dwm may be found under:

git clone http://git.suckless.org/dwm

Modified configuration and dwm.desktop:

curl https://gist.github.com/pawel-zet/4745717/raw/266c30f164a29420cde95e6cb12c0e90dc56e686/config.h -o config.h
curl https://gist.github.com/pawel-zet/4745717/raw/60aba96d3304f3c665f4959823a19bfb4e4e92d7/dwm.desktop -o dwm.desktop

To apply patches and config call:

git apply *.diff
sudo make clean install
cp dwm.desktop /usr/share/xsessions/

To install dmenu

wget http://dl.suckless.org/tools/dmenu-4.5.tar.gz
tar xvf dmenu-4.5.tar.gz
cd dmenu-4.5
sudo make clean install
These are the default keyboard bindings.
M (Mod) should be Alt.
C is Control.
S is Shift.
M+p spawn dmenu
M+S+Return spawn a terminal
M+Space toggle layout
M+b toggle status bar visibility
M+j focus next client
M+k focus previous client
M+g decrease main window/stack ratio
M+s increase main window/stack ratio
M+a pop window from stack ("deiconify")
M+d push window to stack ("iconify")
M+C+y add new workspace
M+C+r remove current workspace (push current windows to stack)
M+m toggle maximization
M+Return zoom window
M+Tab focus next window
M+S+Tab focus previous window
M+S+c kill window
M+l view previous workspace
M+h view next workspace
M+S+l move window to next workspace
M+S+h move window to previous workspace
M+C+l move mouse pointer to next screen (xinerama only)
M+C+h move mouse pointer to previous screen (xinerama only)
M+1 view workspace 1
M+2 view workspace 2
[...]
M+0 view workspace 10
M+S+1 move window to workspace 1
M+S+2 move window to workspace 2
[...]
M+S+0 move window to workspace 10
/* See LICENSE file for copyright and license details. */
/* appearance */
static const char font[] = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*";
static const char normbordercolor[] = "#444444";
static const char normbgcolor[] = "#222222";
static const char normfgcolor[] = "#bbbbbb";
static const char selbordercolor[] = "#005577";
static const char selbgcolor[] = "#005577";
static const char selfgcolor[] = "#eeeeee";
static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
static const Bool showbar = True; /* False means no bar */
static const Bool topbar = True; /* False means bottom bar */
/* 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, True, -1 },
{ "Firefox", NULL, NULL, 1 << 8, False, -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 Bool resizehints = True; /* True 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 WINKEY 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 const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
static const char *termcmd[] = { "uxterm", NULL };
static Key keys[] = {
/* modifier key function argument */
{ WINKEY, XK_b, spawn, SHCMD("firefox") },
{ WINKEY, XK_e, spawn, SHCMD("sublime_text") },
{ 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 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} },
};
[Desktop Entry]
Encoding=UTF-8
Name=DWM
Comment=dynamic window manager
Exec=dwm
Icon=dwm
Type=XSession
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment