Re: [dwm] dwm-5.1 / dmenu-3.8 / sic-1.0 / slock-0.9 / sselp-0.2

2008-07-30 Thread Anselm R Garbe
2008/7/30 Alex Matviychuk [EMAIL PROTECTED]:
 There were also some minor changes to config.h, please use diff(1)
 when upgrading your 5.0.1 config.h in order to prevent bugs.

 How do I map togglemax? Is it still around?

Indirectly, Mod1-m and then Mod1-space

Note, I decided to handle tiled windows only in monocle. This is less
painfull than maximising dialog windows.

Kind regards,
--Anselm



[dwm] DWMII layout for DWM 5.1, a better integration !!!

2008-07-30 Thread QUINTIN Guillaume

Hi all,

This is the DWMII layout for DWM 5.1. It is a layout in the dwm way this 
time ! The only modification is within the Client struct and holds in 11 
chars : int dwmii;\n. This modification prevents from having a more 
complex algorithm and more lines of code. The last release of my layout 
for dwm 5.0.1 contained bugs that I found later. Now, I think it's bug 
free and I review the code for cleaning ! I also added the row layout 
because I missed it. Feel free to try it and send me all your comments.


Kind regards,
QUINTIN Guillaume.
--- dwm.org.c   2008-07-30 12:48:52.0 +0200
+++ dwm.c   2008-07-30 12:56:10.0 +0200
@@ -91,6 +91,7 @@
Client *next;
Client *snext;
Window win;
+   int dwmii;
 };
 
 typedef struct {
@@ -201,6 +202,12 @@
 static int xerrordummy(Display *dpy, XErrorEvent *ee);
 static int xerrorstart(Display *dpy, XErrorEvent *ee);
 static void zoom(const Arg *arg);
+static void dwmiitoggle(const Arg *);
+static void dwmiiinsertafter(Client *,Client *,int);
+static void dwmiikeypressed(const Arg *);
+static void dwmiinoinfiniteloop(void);
+static void dwmiilayoutcol(void);
+static void dwmiilayoutrow(void);
 
 /* variables */
 static char stext[256];
@@ -1742,3 +1749,127 @@
XCloseDisplay(dpy);
return 0;
 }
+
+void dwmiitoggle(const Arg *arg)
+{
+   if ( !lt[sellt]-arrange || (sel  sel-isfloating) ) { return; }
+   Client *firstclients = nexttiled(clients);
+   if ( sel == firstclients ) { return ; }
+   if ( sel-dwmii ) { sel-dwmii = 0; return; }
+   sel-dwmii = 1;
+   arrange();
+}
+
+void dwmiiinsertafter(Client *c,Client *after,int dwmii)
+{
+   if ( !c || !after ) { return; }
+   detach(c);
+   c-dwmii = dwmii;
+   c-next = after-next;
+   after-next = c;
+}
+
+void dwmiikeypressed(const Arg *arg)
+{
+   if ( !lt[sellt]-arrange || (sel  sel-isfloating) ) { return; }
+   Client* firstclients = nexttiled(clients);
+   if ( ( (arg-i == XK_Up)  (lt[sellt]-arrange == dwmiilayoutcol) ) || 
( (arg-i == XK_Left)  (lt[sellt]-arrange == dwmiilayoutrow) ) )
+   {
+   if ( sel-dwmii ) { return; }
+   Client *t = firstclients,*s = 0;
+   for( ; t != sel ; s = t,t = nexttiled(t-next) );
+   sel-dwmii = s-dwmii;
+   dwmiiinsertafter(s,sel,0);
+   }
+   if ( ( (arg-i == XK_Right)  (lt[sellt]-arrange == dwmiilayoutcol) ) 
|| ( (arg-i == XK_Down)  (lt[sellt]-arrange == dwmiilayoutrow) ) )
+   {
+   Client *t = nexttiled(sel-next),*s = 0;
+   if ( !t ) { sel-dwmii = 1; arrange(); return; }
+   int i = 2;
+   for( ; t  ((i -= ( t-dwmii ? 1 : 0 ))  0) ; s = t,t = 
nexttiled(t-next) );
+   if ( sel-dwmii ) { t = nexttiled(sel-next); if ( t ) { 
t-dwmii = 1; } }
+   dwmiiinsertafter(sel,s,( i == 2 ? 1 : 0 ));
+   }
+   if ( ( (arg-i == XK_Down)  (lt[sellt]-arrange == dwmiilayoutcol) ) 
|| ( (arg-i == XK_Right)  (lt[sellt]-arrange == dwmiilayoutrow) ) )
+   {
+   Client *t = nexttiled(sel-next);
+   if ( !t || t-dwmii ) { return; }
+   t-dwmii = sel-dwmii;
+   dwmiiinsertafter(sel,t,0);
+   }
+   if ( ( (arg-i == XK_Left)  (lt[sellt]-arrange == dwmiilayoutcol) ) 
|| ( (arg-i == XK_Up)  (lt[sellt]-arrange == dwmiilayoutrow) ) )
+   {
+   if ( sel == firstclients ) { return; }
+   Client *t = firstclients,*s = 0,*u = 0;
+   for( ; t != sel ; s = t,t = nexttiled(t-next),u = ( t-dwmii ? 
s : u) );
+   if ( !u ) { return; }
+   if ( sel-dwmii ) { t = nexttiled(sel-next); if ( t ) { 
t-dwmii = 1; } }
+   dwmiiinsertafter(sel,u,0);
+   }
+   arrange();
+}
+
+void dwmiinoinfiniteloop(void)
+{
+   Client* firstclients = nexttiled(clients),*t = firstclients;
+   for( ; t  !t-dwmii ; t = nexttiled(t-next) );
+   firstclients-dwmii = 1;
+   if ( t  (t != firstclients) ) { t-dwmii = 0; }
+}
+
+void dwmiilayoutcol(void)
+{
+   Client *firstclients = nexttiled(clients);
+   if ( !firstclients || (lt[sellt]-arrange != dwmiilayoutcol) ) { 
return; }
+   dwmiinoinfiniteloop();
+   Client *t = nexttiled(firstclients-next);
+   int n = 1;
+   for( ; t ; n += ( t-dwmii ? 1 : 0 ),t = nexttiled(t-next) );
+   int x = wx,dw = ww / n; 
+   for ( t = firstclients ; t ; )
+   {
+   if ( t-dwmii )
+   {
+   n = 1;
+   Client *s = nexttiled(t-next);
+   for( ; s  !s-dwmii ; n++,s = nexttiled(s-next) );
+   int dh = wh / n,y = wy + dh;
+   resize(t,x,wy,dw - 2 * t-bw,dh - 2 * 
t-bw,resizehints);
+   for( t = nexttiled(t-next) ; t  !t-dwmii ; t = 
nexttiled(t-next) )
+   {
+   

Re: [dwm] DWMII layout for DWM 5.1, a better integration !!!

2008-07-30 Thread Szabolcs Nagy
On 7/30/08, QUINTIN Guillaume [EMAIL PROTECTED] wrote:
 The only modification is within the Client struct and holds in 11
 chars : int dwmii;\n. This modification prevents from having a more

yes the dwm config.h api is that powerful :)

i'd put all the layout code in a separate file though, and only
include that .c in config.h so the layout could be enabled/disabled
easily, and the patch would be really one extra int in the client
struct (+ possibly a layout entry in config.def.h).



Re: [dwm] DWMII layout for DWM 5.1, a better integration !!!

2008-07-30 Thread pancake
On Wed, 2008-07-30 at 13:14 +0200, QUINTIN Guillaume wrote:
 Hi all,
 
 This is the DWMII layout for DWM 5.1. It is a layout in the dwm way this 
 time ! The only modification is within the Client struct and holds in 11 
 chars : int dwmii;\n. This modification prevents from having a more 
 complex algorithm and more lines of code. The last release of my layout 
 for dwm 5.0.1 contained bugs that I found later. Now, I think it's bug 
 free and I review the code for cleaning ! I also added the row layout 
 because I missed it. Feel free to try it and send me all your comments.
 
 Kind regards,
 QUINTIN Guillaume.

Hi Quintin!

Looks you're working hard to make dwmii fit more in the dwm concepts.

I am currenty a dwm addict, and see no points for using the wmii
approach, but it is an interesting area to play and maybe is somebody
interested on it.

I'll try it :)


Just some comments:

- If its just a layout. distribute it in a separate file and include it
from config.h.

- Write the instructions in the header of your .c file to add the int
dwmii in dwm.c manually.

- I dont see any point for having a function called
dwmiinoinfiniteloop

- conditional and loop brackets should be in the same line (for () {...)
and if () { instead of for()\n{.

- upload it, give an url and update the wiki :)

Fix those minor tips and I'll play with it this night at home!

--pancake

 plain text document attachment (dwmii.patch)
 --- dwm.org.c 2008-07-30 12:48:52.0 +0200
 +++ dwm.c 2008-07-30 12:56:10.0 +0200
 @@ -91,6 +91,7 @@
   Client *next;
   Client *snext;
   Window win;
 + int dwmii;
  };
  
  typedef struct {
 @@ -201,6 +202,12 @@
  static int xerrordummy(Display *dpy, XErrorEvent *ee);
  static int xerrorstart(Display *dpy, XErrorEvent *ee);
  static void zoom(const Arg *arg);
 +static void dwmiitoggle(const Arg *);
 +static void dwmiiinsertafter(Client *,Client *,int);
 +static void dwmiikeypressed(const Arg *);
 +static void dwmiinoinfiniteloop(void);
 +static void dwmiilayoutcol(void);
 +static void dwmiilayoutrow(void);
  
  /* variables */
  static char stext[256];
 @@ -1742,3 +1749,127 @@
   XCloseDisplay(dpy);
   return 0;
  }
 +
 +void dwmiitoggle(const Arg *arg)
 +{
 + if ( !lt[sellt]-arrange || (sel  sel-isfloating) ) { return; }
 + Client *firstclients = nexttiled(clients);
 + if ( sel == firstclients ) { return ; }
 + if ( sel-dwmii ) { sel-dwmii = 0; return; }
 + sel-dwmii = 1;
 + arrange();
 +}
 +
 +void dwmiiinsertafter(Client *c,Client *after,int dwmii)
 +{
 + if ( !c || !after ) { return; }
 + detach(c);
 + c-dwmii = dwmii;
 + c-next = after-next;
 + after-next = c;
 +}
 +
 +void dwmiikeypressed(const Arg *arg)
 +{
 + if ( !lt[sellt]-arrange || (sel  sel-isfloating) ) { return; }
 + Client* firstclients = nexttiled(clients);
 + if ( ( (arg-i == XK_Up)  (lt[sellt]-arrange == dwmiilayoutcol) ) || 
 ( (arg-i == XK_Left)  (lt[sellt]-arrange == dwmiilayoutrow) ) )
 + {
 + if ( sel-dwmii ) { return; }
 + Client *t = firstclients,*s = 0;
 + for( ; t != sel ; s = t,t = nexttiled(t-next) );
 + sel-dwmii = s-dwmii;
 + dwmiiinsertafter(s,sel,0);
 + }
 + if ( ( (arg-i == XK_Right)  (lt[sellt]-arrange == dwmiilayoutcol) ) 
 || ( (arg-i == XK_Down)  (lt[sellt]-arrange == dwmiilayoutrow) ) )
 + {
 + Client *t = nexttiled(sel-next),*s = 0;
 + if ( !t ) { sel-dwmii = 1; arrange(); return; }
 + int i = 2;
 + for( ; t  ((i -= ( t-dwmii ? 1 : 0 ))  0) ; s = t,t = 
 nexttiled(t-next) );
 + if ( sel-dwmii ) { t = nexttiled(sel-next); if ( t ) { 
 t-dwmii = 1; } }
 + dwmiiinsertafter(sel,s,( i == 2 ? 1 : 0 ));
 + }
 + if ( ( (arg-i == XK_Down)  (lt[sellt]-arrange == dwmiilayoutcol) ) 
 || ( (arg-i == XK_Right)  (lt[sellt]-arrange == dwmiilayoutrow) ) )
 + {
 + Client *t = nexttiled(sel-next);
 + if ( !t || t-dwmii ) { return; }
 + t-dwmii = sel-dwmii;
 + dwmiiinsertafter(sel,t,0);
 + }
 + if ( ( (arg-i == XK_Left)  (lt[sellt]-arrange == dwmiilayoutcol) ) 
 || ( (arg-i == XK_Up)  (lt[sellt]-arrange == dwmiilayoutrow) ) )
 + {
 + if ( sel == firstclients ) { return; }
 + Client *t = firstclients,*s = 0,*u = 0;
 + for( ; t != sel ; s = t,t = nexttiled(t-next),u = ( t-dwmii ? 
 s : u) );
 + if ( !u ) { return; }
 + if ( sel-dwmii ) { t = nexttiled(sel-next); if ( t ) { 
 t-dwmii = 1; } }
 + dwmiiinsertafter(sel,u,0);
 + }
 + arrange();
 +}
 +
 +void dwmiinoinfiniteloop(void)
 +{
 + Client* firstclients = nexttiled(clients),*t = firstclients;
 + for( ; t  !t-dwmii ; t = nexttiled(t-next) );
 + firstclients-dwmii = 1;
 + if ( t  (t != firstclients) ) { t-dwmii = 0; }
 +}
 +
 +void dwmiilayoutcol(void)
 +{
 + Client 

Re: [dwm] save cpu cycles - bar status and wrapper scripts

2008-07-30 Thread Alex Matviychuk
Thanks for the suggestion. I tried it out by wrapping the FD readin
block with if(showbar) and it suppressed the output of the while loop
to the dwm bar.

However, to test it out I put an incrementing value in the while block
of my dwm wrapper script and when I re-enable the bar, the value seems
to have kept incrementing since I last disabled the bar. When I first
re-enable, the value is set to the value it was when I disabled the
bar, but on the next iteration jumps to a value that has been
incremented many times since I disabled the bar. So it seems the
output of the while loop is blocked, but the execution continues.

I dug around on google and couldn't find much more info about blocking
the while loop by not reading in from the pipe. The docs just say the
output is blocked, but I think it means the output is suppressed
while the command continues to run.

So this is definitely less code and more elegant, but doesn't quite work.

Cheers,
Alex

On Wed, Jul 23, 2008 at 9:54 PM, Monsieur Pinocchio [EMAIL PROTECTED] wrote:
 On Sat, Jul 19, 2008 at 7:02 PM, Alex Matviychuk [EMAIL PROTECTED] wrote:

 Hello,

 I have a wrapper script for dwm that checks a bunch of devices running
 on my laptop. I was thinking that a lot of times I don't even have the
 dwm bar up (i tend to hide it often for full screen work) and so why
 should the wrapper script constantly poll for status bar info if I
 can't see it. Long story short, I made a small change to write out a
 file to /tmp whenever the status bar is visible. Any thought if this
 is the right approach? Is there a less barbaric way to alert my dwm
 wrapper script that the bar is hidden?

 Diff is attached. I also added a config param to specify the filepath
 for the file that gets written.

 Cheers,
 Alex

 How about just not polling the input fd when bar is disabled? This will
 basically just block the write of the external command which is sending data
 into dwm and cause the external command to go to sleep thus automatically
 stopping it (and resuming it once the bar is shown again).

 --
 Pinocchio



Re: [dwm] save cpu cycles - bar status and wrapper scripts

2008-07-30 Thread Kurt H Maier
Maybe you could not run the script in the loop, and instead trigger it
when you activate the bar.  Something like this:

static const char *barcmd[]  = { /path/to/script  /path/to/pipe, NULL };
...
static Key keys[] = {

{ MODKEY,   XK_b,  spawn,  {.v = barcmd } },
{ MODKEY,   XK_b,  togglebar,  {0} },

The problem is that it will trigger the script again when you _close_
the bar, but that's got to be better than just burning cycles the
whole time.

# Kurt H Maier



On Wed, Jul 30, 2008 at 2:34 PM, Alex Matviychuk [EMAIL PROTECTED] wrote:
 Thanks for the suggestion. I tried it out by wrapping the FD readin
 block with if(showbar) and it suppressed the output of the while loop
 to the dwm bar.

 However, to test it out I put an incrementing value in the while block
 of my dwm wrapper script and when I re-enable the bar, the value seems
 to have kept incrementing since I last disabled the bar. When I first
 re-enable, the value is set to the value it was when I disabled the
 bar, but on the next iteration jumps to a value that has been
 incremented many times since I disabled the bar. So it seems the
 output of the while loop is blocked, but the execution continues.

 I dug around on google and couldn't find much more info about blocking
 the while loop by not reading in from the pipe. The docs just say the
 output is blocked, but I think it means the output is suppressed
 while the command continues to run.

 So this is definitely less code and more elegant, but doesn't quite work.

 Cheers,
 Alex

 On Wed, Jul 23, 2008 at 9:54 PM, Monsieur Pinocchio [EMAIL PROTECTED] wrote:
 On Sat, Jul 19, 2008 at 7:02 PM, Alex Matviychuk [EMAIL PROTECTED] wrote:

 Hello,

 I have a wrapper script for dwm that checks a bunch of devices running
 on my laptop. I was thinking that a lot of times I don't even have the
 dwm bar up (i tend to hide it often for full screen work) and so why
 should the wrapper script constantly poll for status bar info if I
 can't see it. Long story short, I made a small change to write out a
 file to /tmp whenever the status bar is visible. Any thought if this
 is the right approach? Is there a less barbaric way to alert my dwm
 wrapper script that the bar is hidden?

 Diff is attached. I also added a config param to specify the filepath
 for the file that gets written.

 Cheers,
 Alex

 How about just not polling the input fd when bar is disabled? This will
 basically just block the write of the external command which is sending data
 into dwm and cause the external command to go to sleep thus automatically
 stopping it (and resuming it once the bar is shown again).

 --
 Pinocchio





Re: [dwm] save cpu cycles - bar status and wrapper scripts

2008-07-30 Thread Szabolcs Nagy
On 7/30/08, Kurt H Maier [EMAIL PROTECTED] wrote:
 static const char *barcmd[]  = { /path/to/script  /path/to/pipe, NULL };

SHCMD(/path/to/script  /path/to/pipe) macro should be used there

(so the '' is interpreted by the shell)



[dwm] DWMII layout with a more better integration

2008-07-30 Thread QUINTIN Guillaume

Hi all and pancake !


This is the dwmii.c file containing the dwmii layout with the 
instructions to make it work !


@pancake :

 I dont see any point for having a function called
 dwmiinoinfiniteloop

Well this function is necessary, I didn't know how to call it, though 
its name is relevant... If you don't like its name feel free to change 
it but I won't. The important thing is that it does its job.


 conditional and loop brackets should be in the same line (for () {...)
 and if () { instead of for()\n{.

Well, everyone has its habits, since it does not alterate the quality of 
the code.


Kind regards,
QUINTIN Guillaume
/*
 * I used WMII and found it too heavy. So I switched to dwm but I
 * quickly missed the possibilities of having several columns,
 * several windows in each column and moving the windows from a
 * column into another or change the windows' order within a column.
 * As there were no patch (or layout) providing that, I wrote one.
 * I also added a layout that does the same thing but arrange the
 * windows by rows.
 *
 * The col dwmii layout :
 *
 *   +--+--+--+
 *   |  |  |  |
 *   +--+  |  |
 *   |  +--+  |
 *   +--+  |  |
 *   |  |  |  |
 *   +--+--+--+
 *
 * The row dwmii layout :
 *
 *   +--+---+--+
 *   +  |   |  +
 *   +--+-+-+--+
 *   |||
 *   +++
 *   | |
 *   +-+
 *
 * You can move a window to the next/previous columnn, after the next
 * window or before the previous window within a column by simple
 * combination of keys (the same as in WMII).
 *
 * To get the dwmii layouts working you have to :
 * - have DWM version 5.1
 * - add these lines in the config.h file :
 *   - just before the layouts array :
 *
 * #include dwmii.c 
 *
 *   - in the layouts array :
 *
 * { COL, dwmiilayoutcol },
 * { ROW, dwmiilayoutrow },
 *
 *   - in the keys array :
 *
 * { MODKEY,   XK_c,  setlayout,   {.v = layouts[1]} },
 * { MODKEY,   XK_r,  setlayout,   {.v = layouts[2]} },
 * { MODKEY|ShiftMask, XK_Up, dwmiikeypressed, {.i = XK_Up} },
 * { MODKEY|ShiftMask, XK_Left,   dwmiikeypressed, {.i = XK_Left} },
 * { MODKEY|ShiftMask, XK_Down,   dwmiikeypressed, {.i = XK_Down} },
 * { MODKEY|ShiftMask, XK_Right,  dwmiikeypressed, {.i = XK_Right} },
 * { MODKEY|ShiftMask, XK_n,  dwmiitoggle, {0} },
 *
 * - add this line in the Client struct definition in the dwm.c file :
 *
 *   int dwmii;
 *
 * - compile and it should work !
 *
 * The dwmiitoggle sets the dwmii variable of a window, when
 * the dwmii is non zero then the window marks the start of a
 * new column/row depending on the layout used.
 *
 * Enjoy it and feel free to send me all your comments !
 *
 * QUINTIN Guillaume
 *
 */

static void dwmiitoggle(const Arg *);
static void dwmiiinsertafter(Client *,Client *,int);
static void dwmiikeypressed(const Arg *);
static void dwmiinoinfiniteloop(void);
static void dwmiilayoutcol(void);
static void dwmiilayoutrow(void);
 
void dwmiitoggle(const Arg *arg)
{
	if ( !lt[sellt]-arrange || (sel  sel-isfloating) ) { return; }
	Client *firstclients = nexttiled(clients);
	if ( sel == firstclients ) { return ; }
	if ( sel-dwmii ) { sel-dwmii = 0; return; }
	sel-dwmii = 1;
	arrange();
}

void dwmiiinsertafter(Client *c,Client *after,int dwmii)
{
	if ( !c || !after ) { return; }
	detach(c);
	c-dwmii = dwmii;
	c-next = after-next;
	after-next = c;
}

void dwmiikeypressed(const Arg *arg)
{
	if ( !lt[sellt]-arrange || (sel  sel-isfloating) ) { return; }
	Client* firstclients = nexttiled(clients);
	if ( ( (arg-i == XK_Up)  (lt[sellt]-arrange == dwmiilayoutcol) ) || ( (arg-i == XK_Left)  (lt[sellt]-arrange == dwmiilayoutrow) ) )
	{
		if ( sel-dwmii ) { return; }
		Client *t = firstclients,*s = 0;
		for( ; t != sel ; s = t,t = nexttiled(t-next) );
		sel-dwmii = s-dwmii;
		dwmiiinsertafter(s,sel,0);
	}
	if ( ( (arg-i == XK_Right)  (lt[sellt]-arrange == dwmiilayoutcol) ) || ( (arg-i == XK_Down)  (lt[sellt]-arrange == dwmiilayoutrow) ) )
	{
		Client *t = nexttiled(sel-next),*s = 0;
		if ( !t ) { sel-dwmii = 1; arrange(); return; }
		int i = 2;
		for( ; t  ((i -= ( t-dwmii ? 1 : 0 ))  0) ; s = t,t = nexttiled(t-next) );
		if ( sel-dwmii ) { t = nexttiled(sel-next); if ( t ) { t-dwmii = 1; } }
		dwmiiinsertafter(sel,s,( i == 2 ? 1 : 0 ));
	}
	if ( ( (arg-i == XK_Down)  (lt[sellt]-arrange == dwmiilayoutcol) ) || ( (arg-i == XK_Right)  (lt[sellt]-arrange == dwmiilayoutrow) ) )
	{
		Client *t = nexttiled(sel-next);
		if ( !t || t-dwmii ) { return; }
		t-dwmii = sel-dwmii;
		dwmiiinsertafter(sel,t,0);
	}
	if ( ( (arg-i == XK_Left)  (lt[sellt]-arrange == dwmiilayoutcol) ) || ( (arg-i == XK_Up)  (lt[sellt]-arrange == dwmiilayoutrow) ) )
	{
		if ( sel == firstclients ) { return; }
		Client *t = firstclients,*s = 0,*u = 0;
		for( ; t != sel ; s = t,t = nexttiled(t-next),u = ( t-dwmii ? s : u) );
		if ( !u ) { return; }
		if ( sel-dwmii ) { t = nexttiled(sel-next); if ( t ) { t-dwmii = 1; } }
		

Re: [dwm] DWMII layout with a more better integration

2008-07-30 Thread Donald Chai

@pancake :

 I dont see any point for having a function called
 dwmiinoinfiniteloop

Well this function is necessary, I didn't know how to call it,  
though its name is relevant... If you don't like its name feel free  
to change it but I won't. The important thing is that it does its job.


I think what pancake meant is that code that needs a function  
called dwmiinoinfiniteloop can usually be rewritten to not require  
it, improving maintainability. From what I can tell, it unsets the  
second dwmii bit it finds, merging the second column of windows into  
the first column. Why?


--snip--


void dwmiinoinfiniteloop(void)
{
Client* firstclients = nexttiled(clients),*t = firstclients;
for( ; t  !t-dwmii ; t = nexttiled(t-next) );
firstclients-dwmii = 1;
if ( t  (t != firstclients) ) { t-dwmii = 0; }
}


The code below contains lots of if's that seem to be always true  
(or should be). Why check them? You don't call dwmiilayoutcol unless  
if (lt[sellt]-arrange == dwmiilayoutcol). Also, the line

if (t-dwmii)
should always be true. Otherwise, you'll get an infinite loop. I  
think it'd be better to remove this check (and not explicitly set  
firstclients-dwmii=1). This might work better for the case of  
windows having multiple tags...



void dwmiilayoutcol(void)
{
Client *firstclients = nexttiled(clients);
	if ( !firstclients || (lt[sellt]-arrange != dwmiilayoutcol) )  
{ return; }

dwmiinoinfiniteloop();
Client *t = nexttiled(firstclients-next);
int n = 1;
for( ; t ; n += ( t-dwmii ? 1 : 0 ),t = nexttiled(t-next) );
int x = wx,dw = ww / n; 
for ( t = firstclients ; t ; )
{
if ( t-dwmii )
{
n = 1;
Client *s = nexttiled(t-next);
for( ; s  !s-dwmii ; n++,s = nexttiled(s-next) );
int dh = wh / n,y = wy + dh;
resize(t,x,wy,dw - 2 * t-bw,dh - 2 * 
t-bw,resizehints);
			for( t = nexttiled(t-next) ; t  !t-dwmii ; t = nexttiled(t- 
next) )

{
resize(t,x,y,dw - 2 * t-bw,dh - 2 * 
t-bw,resizehints);
y += dh;
}
x += dw;
}
}
}





[dwm] unsigned int or size_t

2008-07-30 Thread Filippo Erik Negroni
Hi All,

I noticed the code in dwm uses unsigned int for positive counters of
memory arrays instead of size_t.
Is there a particular reason you don't use size_t in order to convey
that you are using that quantity as a counter of memory space?

-- 
Cheers,
Filippo



Re: [dwm] DockBox - A Tiling Window Manager for Windows

2008-07-30 Thread hiro
Thanks, that's interesting.



Re: [dwm] save cpu cycles - bar status and wrapper scripts

2008-07-30 Thread Alex Matviychuk
Works like a champ! Here is my script setup (please let me know if I
can improve anything):

.xinitrc:
--
...
rmdir /tmp/dwm-bar-script-lock
dwm-statusbar 
dwm-launch


dwm-statusbar:
--
#!/bin/bash
#Incrementing numbers are just for testing.

LOCK=/tmp/dwm-bar-script-lock

if mkdir $LOCK; then
i=0
while [ -e $SHOWBAR ]; do
((i++))
echo $i [`date '+%a %b %d %I:%M%P'`]
sleep 1
done  /tmp/dwmpipe
else
rmdir $LOCK
killall dwm-statusbar
fi


dwm-launch:
-
#!/bin/bash

DWM_PIPE=/tmp/dwmpipe

if [ ! -e $DWM_PIPE ]; then
mkfifo $DWM_PIPE
fi

while true; do
cat $DWM_PIPE
done | dwm


config.h:

...
static const char *barcmd[]  = { dwm-statusbar, NULL };
...
static Key keys[] = {
{ MODKEY,   XK_b,  spawn,
{.v = barcmd } },
{ MODKEY,   XK_b,  togglebar,  {0} },
...


Now I don't have to patch DWM at all... well... at least not for this
feature, haha :)

Cheers,
Alex

On Wed, Jul 30, 2008 at 12:49 PM, Kurt H Maier [EMAIL PROTECTED] wrote:
 Maybe you could not run the script in the loop, and instead trigger it
 when you activate the bar.  Something like this:

 static const char *barcmd[]  = { /path/to/script  /path/to/pipe, NULL };
 ...
 static Key keys[] = {
 
 { MODKEY,   XK_b,  spawn,  {.v = barcmd } },
 { MODKEY,   XK_b,  togglebar,  {0} },

 The problem is that it will trigger the script again when you _close_
 the bar, but that's got to be better than just burning cycles the
 whole time.

 # Kurt H Maier



 On Wed, Jul 30, 2008 at 2:34 PM, Alex Matviychuk [EMAIL PROTECTED] wrote:
 Thanks for the suggestion. I tried it out by wrapping the FD readin
 block with if(showbar) and it suppressed the output of the while loop
 to the dwm bar.

 However, to test it out I put an incrementing value in the while block
 of my dwm wrapper script and when I re-enable the bar, the value seems
 to have kept incrementing since I last disabled the bar. When I first
 re-enable, the value is set to the value it was when I disabled the
 bar, but on the next iteration jumps to a value that has been
 incremented many times since I disabled the bar. So it seems the
 output of the while loop is blocked, but the execution continues.

 I dug around on google and couldn't find much more info about blocking
 the while loop by not reading in from the pipe. The docs just say the
 output is blocked, but I think it means the output is suppressed
 while the command continues to run.

 So this is definitely less code and more elegant, but doesn't quite work.

 Cheers,
 Alex

 On Wed, Jul 23, 2008 at 9:54 PM, Monsieur Pinocchio [EMAIL PROTECTED] 
 wrote:
 On Sat, Jul 19, 2008 at 7:02 PM, Alex Matviychuk [EMAIL PROTECTED] wrote:

 Hello,

 I have a wrapper script for dwm that checks a bunch of devices running
 on my laptop. I was thinking that a lot of times I don't even have the
 dwm bar up (i tend to hide it often for full screen work) and so why
 should the wrapper script constantly poll for status bar info if I
 can't see it. Long story short, I made a small change to write out a
 file to /tmp whenever the status bar is visible. Any thought if this
 is the right approach? Is there a less barbaric way to alert my dwm
 wrapper script that the bar is hidden?

 Diff is attached. I also added a config param to specify the filepath
 for the file that gets written.

 Cheers,
 Alex

 How about just not polling the input fd when bar is disabled? This will
 basically just block the write of the external command which is sending data
 into dwm and cause the external command to go to sleep thus automatically
 stopping it (and resuming it once the bar is shown again).

 --
 Pinocchio