Moved to dwm.

I’m a Gnome user for along time and just decided to move to a simple , small , stable and fast window manager i found lots of them online like wmi , wmii , dwm , fluxbox , openbox , blackbox …etc and from all of these window managers i tried most of them and i liked just one of them for some reasion i don’t know and its DWM, its simple , fast, easy to develope and stable here’s a description of it on there website http://suckless.org/dwm :

dwm is a dynamic window manager for X. It manages windows in tiled and floating layouts. Either layout can be applied dynamically, optimizing the environment for the application in use and the task performed. It is the little brother of wmii.

my dwm screenshot :

dwm screenshot

dwm screenshot

in this post i’ll show you how did i downloaded it and configured it , the lastest stable version is dwm-5.1 but im using dwm-4.7 don’t ask why!! you can download that version from

http://code.suckless.org/dl/dwm/dwm-4.7.tar.gz

as you can see there are 7 files

config.def.h is the configure file that config almost everything including appearance, tabs..etc

config.mk is the makefile configure

dwm.c is the main and only sourcecode of dwm (dynamic window manager)

Makefile is obviously the makefile !! :P

so where are going to deal only with config.def.h

first you have to move it from config.def.h to config.h and then edit that file as you like here’s my config.h file which should be useful for you ..

/* dwm configure file created
 * by qnix
 * */

/* appearance */
#define BARPOS			BarTop /* BarBot, BarOff */
#define BORDERPX		2
#define FONT			"-*-bitstream vera sans mono-medium-r-normal-*-10-*-*-*-*-*-*-*"
#define NORMBORDERCOLOR		"#222222"
#define NORMBGCOLOR		"#222222"
#define NORMFGCOLOR		"#cccccc"
#define SELBORDERCOLOR		"#222222"
#define SELBGCOLOR		"#222222"
#define SELFGCOLOR		"#ffffff"
#define TOPBAR			True

/* tagging */
const char tags[][MAXTAGLEN] = { "main", "dev", "chat", "www", "media", "other" };
Bool seltags[LENGTH(tags)] = {[0] = True};
Rule rules[] = {
	/* class:instance:title regex	tags regex	isfloating */
	{ "Firefox",			"www",		False },
	{ "xchat",			"chat",		False },
	{ "Gimp",			"media",	True  },
	{ "MPlayer",			"media",	True  },
	{ "skype",			"chat",		False },
	{ "Acroread",			"other",	True  },
	{ "pidgin",			"chat",		False },
	{ "gvim",			"dev",		False },
	{ "eclipse",			"dev",		True  },
};

/* layout(s) */
#define MWFACT			0.6	/* master width factor [0.1 .. 0.9] */
#define RESIZEHINTS		True	/* False - respect size hints in tiled resizals */
#define SNAP			32	/* snap pixel */
Layout layouts[] = {
	/* symbol		function */
	{ "o_o",		floating },	// first entry is default
	{ "0_0",		tile },
};

/* key definitions */
#define MODKEY			Mod1Mask
Key keys[] = {
	/* modifier			key		function	argument */
	{ MODKEY,			XK_p,		spawn,
		"exe=`dmenu_path | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"'"
		" -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'` && exec $exe" },
	{ MODKEY|ShiftMask,		XK_Return,	spawn, "exec gnome-terminal --hide-menubar" },
	{ MODKEY,			XK_space,	setlayout,	NULL },
	{ MODKEY,			XK_b,		togglebar,	NULL },
	{ MODKEY,			XK_j,		focusnext,	NULL },
	{ MODKEY,			XK_k,		focusprev,	NULL },
	{ MODKEY,			XK_h,		setmwfact,	"-0.05" },
	{ MODKEY,			XK_l,		setmwfact,	"+0.05" },
	{ MODKEY,			XK_m,		togglemax,	NULL },
	{ MODKEY,			XK_Return,	zoom,		NULL },
	{ MODKEY,			XK_Tab,		viewprevtag,	NULL },
	{ MODKEY|ShiftMask,		XK_space,	togglefloating,	NULL },
	{ MODKEY|ShiftMask,		XK_c,		killclient,	NULL },
	{ MODKEY,			XK_0,		view,		NULL },
	{ MODKEY,			XK_1,		view,		tags[0] },
	{ MODKEY,			XK_2,		view,		tags[1] },
	{ MODKEY,			XK_3,		view,		tags[2] },
	{ MODKEY,			XK_4,		view,		tags[3] },
	{ MODKEY,			XK_5,		view,		tags[4] },
	{ MODKEY,			XK_6,		view,		tags[5] },
	{ MODKEY,			XK_7,		view,		tags[6] },
	//{ MODKEY,			XK_8,		view,		tags[7] },
	//{ MODKEY,			XK_9,		view,		tags[8] },
	{ MODKEY|ControlMask,		XK_1,		toggleview,	tags[0] },
	{ MODKEY|ControlMask,		XK_2,		toggleview,	tags[1] },
	{ MODKEY|ControlMask,		XK_3,		toggleview,	tags[2] },
	{ MODKEY|ControlMask,		XK_4,		toggleview,	tags[3] },
	{ MODKEY|ControlMask,		XK_5,		toggleview,	tags[4] },
	{ MODKEY|ControlMask,		XK_6,		toggleview,	tags[5] },
	{ MODKEY|ControlMask,		XK_7,		toggleview,	tags[6] },
	//{ MODKEY|ControlMask,		XK_8,		toggleview,	tags[7] },
	//{ MODKEY|ControlMask,		XK_9,		toggleview,	tags[8] },
	{ MODKEY|ShiftMask,		XK_0,		tag,		NULL },
	{ MODKEY|ShiftMask,		XK_1,		tag,		tags[0] },
	{ MODKEY|ShiftMask,		XK_2,		tag,		tags[1] },
	{ MODKEY|ShiftMask,		XK_3,		tag,		tags[2] },
	{ MODKEY|ShiftMask,		XK_4,		tag,		tags[3] },
	{ MODKEY|ShiftMask,		XK_5,		tag,		tags[4] },
	{ MODKEY|ShiftMask,		XK_6,		tag,		tags[5] },
	{ MODKEY|ShiftMask,		XK_7,		tag,		tags[6] },
	//{ MODKEY|ShiftMask,		XK_8,		tag,		tags[7] },
	//{ MODKEY|ShiftMask,		XK_9,		tag,		tags[8] },
	{ MODKEY|ControlMask|ShiftMask,	XK_1,		toggletag,	tags[0] },
	{ MODKEY|ControlMask|ShiftMask,	XK_2,		toggletag,	tags[1] },
	{ MODKEY|ControlMask|ShiftMask,	XK_3,		toggletag,	tags[2] },
	{ MODKEY|ControlMask|ShiftMask,	XK_4,		toggletag,	tags[3] },
	{ MODKEY|ControlMask|ShiftMask,	XK_5,		toggletag,	tags[4] },
	{ MODKEY|ControlMask|ShiftMask,	XK_6,		toggletag,	tags[5] },
	{ MODKEY|ControlMask|ShiftMask,	XK_7,		toggletag,	tags[6] },
	//{ MODKEY|ControlMask|ShiftMask,	XK_8,		toggletag,	tags[7] },
	//{ MODKEY|ControlMask|ShiftMask,	XK_9,		toggletag,	tags[8] },
	{ MODKEY|ShiftMask,		XK_9, 		spawn,		"exec setxkbmap us" },
	{ MODKEY|ShiftMask,		XK_8,		spawn,		"exec setxkbmap ar" },
	{ MODKEY|ShiftMask,		XK_q,		quit,		NULL },
};

for more information about setting the config.h file check out suckless.org/dwm website.. so now after downloading and configuring it we will install it with this command

qnix@~/dwm-4.7$ make clean install

now dwm is installed you have to configure the xsessions

qnix@~$ whereis xsessions
xsessions: /usr/share/xsessions
qnix@~$ cd /usr/share/xsessions/

and in that folder create a file called dwm.desktop and add these line to it

[Desktop Entry]
Encoding=UTF-8
Name=Dwm
Comment=Dynamic window manager
Exec=dwm-launch
Icon=dwm.png
Type=XSession

now create a file in /usr/local/bin called dwm-launch which set the background image
and will print the time+date on top-left of dwm

feh --bg-scale /root/Pictures/Wallpapers/dwm.wall.by.PhrAok.png
while true
do
echo "[`date '+%a %b %d %r'`"]
sleep 2
done | dwm

don’t forget about the ‘feh’ command which is a tool to set the background image you have to install it and now for viewing GTK programe in a beautiful way you have to create a file in $HOME/.gtkrc-2.0 i created that file using a tool called “gtk-chtheme” checkout http://plasmasturm.org/code/gtk-chtheme/ for more information … that’s pretty much all…
by the way if you see my config.h file that i wrote previously it contains a code for setxkbmap that changes the keyboard layout .. you can add your layouts by editting the xorg.conf which might be in /etc/X11/xorg.conf and search for these lines

Section "InputDevice"
        Identifier      "Generic Keyboard"
        Driver          "kbd"
        Option          "XkbRules"      "xorg"
        Option          "XkbModel"      "pc105"
        Option          "XkbLayout"     "us,ar"
EndSection
        Option          "XkbLayout"     "us,ar"

as you can see us,ar means “English” and “Arabic”
MMmmm you can add more things to your dwm like conky which is a system monitor for X..
now that’s it!! :-D hope you’ll enjoy your new and simple , fast , stable window manager

;)

7 thoughts on “Moved to dwm.”

  1. nice interface i will give a shot on my old FreeBSD box, its there in the port tree.

    [root@h4x0r ~]$whereis dwm
    dwm: /usr/ports/x11-wm/dwm

  2. Don’t install it from the port it will be with the default configuration i am sure you want to configure it more as you need,
    so download the source code and play with the configure file :-D
    and enjoy the simplicity

  3. Good info, but you should reverse the ‘make clean install’ to read ‘make install clean’. Make won’t clean out the left over files before doing the install, so what you have now doesn’t really do much.

  4. Nice post ;)

    On FreeBSD simply do the following:
    $ su
    # cd /usr/ports/x11-wm/dwm ; make DWM_CONF=/path/to/dwm/config.h install clean

    This info is available in dwm’s Makefile at /usr/ports/x11-wm/dwm/Makefile.

    Basically this we simply use the DWM_CONF knob.

    You did well in identifying the version of dwm you’ve used for the post. Many things have changed since 4.7.

    Keep up the good work.

  5. Hi! I changed my own config.h and xorg.conf in a similar manner, but using latam and ru keyboard layouts and it doesn’t work. Did you do anything special for those combos to work?

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>