[dwm] [patch] Stack columns patch for dwm-4.4.1

2007-09-09 Thread Chris Webb
Below is a patch for the current release (4.4.1) of dwm which enables
multiple columns in the stacking area. It introduces variables nrows and
ncols with corresponding default values NROWS and NCOLS in
config.h.default, and corresponding setnrows() and setncols() for use in
keybindings.

If nrows == ncols == 0, tile() behaves in the normal manner. When nrows 
0, tile() creates an extra column if adding another window to the current
one would cause it to exceed nrows clients. If ncols  0, the maximum
number of columns created cannot exceed ncols, overriding the nrows
setting. The patch also reintroduces nmaster in a similar way to the
existing nmaster patch, but allows it to be zero to simulate a grid mode.
Where there are not enough windows to fill all the columns evenly, the
extra space is used by the top-most client in the first column.

I'd be interested in any feedback. (I use this 'extended tiling' mode
myself, and so intend to maintain the patch going forward.)

Best wishes,

Chris.


diff -uNrd dwm-4.4.1.orig/config.default.h dwm-4.4.1/config.default.h
--- dwm-4.4.1.orig/config.default.h 2007-08-26 11:53:49.0 +0100
+++ dwm-4.4.1/config.default.h  2007-09-09 16:35:23.0 +0100
@@ -33,6 +33,9 @@
{ ,floating }, \
 };
 #define MWFACT 0.6 /* master width factor [0.1 .. 0.9] */
+#define NMASTER1   /* clients in master area */
+#define NROWS  2   /* clients per column in stacking area 
*/
+#define NCOLS  3   /* maximum number of stacking area 
columns */
 #define SNAP   32  /* snap pixel */
 
 /* key definitions */
@@ -48,6 +51,12 @@
{ MODKEY,   XK_k,   focusprev,  NULL }, 
\
{ MODKEY,   XK_h,   setmwfact,  -0.05 
}, \
{ MODKEY,   XK_l,   setmwfact,  +0.05 
}, \
+   { MODKEY|ShiftMask, XK_j,   setnrows,   -1 }, 
\
+   { MODKEY|ShiftMask, XK_k,   setnrows,   +1 }, 
\
+   { MODKEY|ControlMask,   XK_j,   setncols,   -1 }, 
\
+   { MODKEY|ControlMask,   XK_k,   setncols,   +1 }, 
\
+   { MODKEY|ShiftMask, XK_h,   setnmaster, -1 }, 
\
+   { MODKEY|ShiftMask, XK_l,   setnmaster, +1 }, 
\
{ MODKEY,   XK_m,   togglemax,  NULL }, 
\
{ MODKEY,   XK_Return,  zoom,   NULL }, 
\
{ MODKEY|ShiftMask, XK_space,   togglefloating, NULL }, 
\
diff -uNrd dwm-4.4.1.orig/tile.c dwm-4.4.1/tile.c
--- dwm-4.4.1.orig/tile.c   2007-08-26 11:53:49.0 +0100
+++ dwm-4.4.1/tile.c2007-09-09 16:34:17.0 +0100
@@ -5,10 +5,82 @@
 /* static */
 
 static double mwfact = MWFACT;
+static unsigned int nmaster = NMASTER;
+static unsigned int nrows = NROWS;
+static unsigned int ncols = NCOLS;
 
 /* extern */
 
 void
+setnmaster(const char *arg) {
+   int i;
+
+   if(!isarrange(tile))
+   return;
+   if(!arg)
+   i = NMASTER;
+   else if(arg[0] != '+'  arg[0] != '-')
+   i = atoi(arg);
+   else
+   i = nmaster + atoi(arg);
+
+   if(i  0 || wah = 2 * BORDERPX * i)
+   return;
+   
+   nmaster = i;
+   if(sel)
+   arrange();
+   else
+   drawstatus();
+}
+
+void
+setnrows(const char *arg) {
+   int i;
+
+   if(!isarrange(tile))
+   return;
+   if(!arg)
+   i = NROWS;
+   else if(arg[0] != '+'  arg[0] != '-')
+   i = atoi(arg);
+   else
+   i = nrows + atoi(arg);
+
+   if(i  0 || wah = 2 * BORDERPX * i)
+   return;
+   nrows = i;
+
+   if(sel)
+   arrange();
+   else
+   drawstatus();
+}
+
+void
+setncols(const char *arg) {
+   int i;
+
+   if(!isarrange(tile))
+   return;
+   if(!arg)
+   i = NCOLS;
+   else if(arg[0] != '+'  arg[0] != '-')
+   i = atoi(arg);
+   else
+   i = ncols + atoi(arg);
+
+   if((i  0) || (i = 1  waw / i = 2 * BORDERPX))
+   return;
+   ncols = i;
+
+   if(sel)
+   arrange();
+   else
+   drawstatus();
+}
+
+void
 setmwfact(const char *arg) {
double delta;
 
@@ -32,40 +104,79 @@
 
 void
 tile(void) {
-   unsigned int i, n, nx, ny, nw, nh, mw, th;
+   unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th, tw1, cols, rows, 
rows1;
Client *c;
 
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c-next))
n++;
 
+   /* calculate correct number of rows */
+   if(ncols  0  n - nmaster  nrows * ncols)
+   rows = (n - nmaster) / ncols + ((n - nmaster) % ncols ? 1 : 

[dwm] Dwm and Ubuntu -- how to keep nifty UI features?

2007-09-09 Thread Kai Grossjohann
Having been a Debian user, I now got an Ubuntu box and I wonder what is
the best approach to running dwm on it, so that I won't lose the nifty
UI features that Ubuntu offers, such as the Network Manager and the
update notifications.

Any advice?

(Actually, I use xmonad, but the answers will be applicable to both
window managers, I'm sure.  I ask here because I believe that arg
mentioned Ubuntu before.)

Kai




Re: [dwm] Dwm and Ubuntu -- how to keep nifty UI features?

2007-09-09 Thread T Biehn
Network Manager is a gnome-panel applet, when I needed to use it (which I no
longer do, as using the console is better for this anyways) i put
gnome-panel as a floating window rule, then would launch it and then
nm-applet do my config stuff then kill it.
Otherwise I guess maybe gnome has some sort of standard applet dock code
that you can specify some random area on the screen for it to draw images /
put an icon but thats a lot more work than I guess anyone is willing to do.

I'd suggest just doing update-manager / familiarizing yourself with debian
ifup,ifdown, apt-get (crontab with echo  dwm-stdio pipe?) and linux
ifconfig iwconfig commands, or running gnome-panel as a float in a tag.

On 9/9/07, Kai Grossjohann [EMAIL PROTECTED] wrote:

 Having been a Debian user, I now got an Ubuntu box and I wonder what is
 the best approach to running dwm on it, so that I won't lose the nifty
 UI features that Ubuntu offers, such as the Network Manager and the
 update notifications.

 Any advice?

 (Actually, I use xmonad, but the answers will be applicable to both
 window managers, I'm sure.  I ask here because I believe that arg
 mentioned Ubuntu before.)

 Kai