Posts Tagged ‘dwm’

tiling window manager on the mac

January 28th, 2011 6 comments

I recently switched to the awesome (thats the name !!!) wm on my linux box (lets see how long that one will last). So i decided to have dwm up and running again on my mac. Thats rather usefull when working with many terminals at once . . .
First thing is to get the newest XQuartz: – normal X11 produced some wierd key-codes on my site so i switched to XQuartz . . .
Now is the time to get the sources for dwm from and while you’re there grab dmenu as well: Compile and install both somewhere your shell can find them.

Here are the relevant parts of dwm’s config.h:

static const char font[]            = "-*-fixed-medium-r-*-*-15-*-*-*-*-*-*-*";
static const char normbordercolor[] = "#cccccc";
static const char normbgcolor[]     = "#cccccc";
static const char normfgcolor[]     = "#000000";
static const char selbordercolor[]  = "#0066ff";
static const char selbgcolor[]      = "#0066ff";
static const char selfgcolor[]      = "#ffffff";
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 */
static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
static const char *termcmd[]  = { "uxterm", "-font", font, "+cm", "-pc", "-rv", "-sl", "2000", NULL };
	TAGKEYS(                        XK_9,                      8)
	{ MODKEY|ControlMask,           XK_q,      quit,           {0} },

The last line ensures that you do not overlay the quit keycode with the logout-functionality of mac-os-x.

To have dwm start when starting XQuartz create or edit .xinitrc and .Xdefaults in your $HOME. Here’s the actual content of these files on my hardrive

cd ~
exec >>~/.xsession-errors 2>&1
export MANPATH=${MANPATH}:/Users/william/Software/app/dwm/share/man
export PATH=${PATH}:/Users/william/Software/app/dwm/bin
export DATE=`date +"%Y-%m-%d"`
while true
  xsetroot -name "$DATE"
  sleep 3600
done &
#xsetroot -solid '#4a525a'
#xmodmap -e 'remove Mod2 = Meta_L' -e 'add Mod1 = Meta_L'
exec dwm


# File : .Xresources
xterm*font:  -*-fixed-bold-r-*-*-15-*-*-*-*-*-*-*
xterm*font1: -*-fixed-medium-r-*-*-18-*-*-*-*-*-iso8859-*
xterm*font2: -*-*-*-*-*-*-2-*-*-*-*-*-*-*
xterm*font3: -misc-fixed-*-r-normal-*-8-*-*-*-*-*-iso8859-*
xterm*font4: -b&h-lucidatypewriter-bold-*-*-*-12-*-*-*-*-*-*-*
xterm*font5: -*-screen-bold-r-normal-*-16-*-*-*-*-*-iso8859-*
xterm*font6: -*-lucidatypewriter-medium-*-*-*-18-*-*-*-*-*-*-*
xterm*font7: -*-lucidatypewriter-medium-*-*-*-20-*-*-*-*-*-*-*
xterm*font8: -dec-terminal-bold-r-normal-*-14-*-*-*-*-*-iso8859-*
XTerm*background: black
XTerm*foreground: white
#XTerm*pointerColor: blue
#XTerm*pointerColorBackground: black
#XTerm*cursorColor: navy
#XTerm*internalBorder: 3
XTerm*loginShell: true
XTerm*scrollBar: false
XTerm*scrollKey: true
XTerm*saveLines: 1000
XTerm*multiClickTime: 250

Now dwn should startup when XQuartz ist launched. To make the Alt-keys work you have to switch on the corresponding option under X11->Preferences->Input “Option keys send Alt_L and Alt_R” and I’d also suggest enabling “Emulate three button mouse”.

The key combo shift-alt-enter now starts a new shell. Open a few more. Now you use Alt-j to cycle forward through your shells and Alt-k to cycle backwards. Alt+enter switches the actual shell to the biggest frame on the left. Alt-h and Alt-l move the border between the main shell and the sub-shells by 5% per keystroke.

With alt+number you can switch between the 9 different screens. Using shift-alt-number moves the shell/program with focus to the desired screen.

Starting other apps than the shell is easily done by using dmenu that is started with alt-p. This shows the list of possible target-apps as an overlay to the top-bar. Just type in the first few letters of the app you want to start to refine your selection to the point were you can use the cursor keys to highlight the right name and then press enter to start. You can even use parts of the app-name that are not at the beginning of the word – for example to start xcutsel its sufficient to type in “tsel” :

Rock on 😉

Categories: nerdcore, software Tags: ,