[dwm] nmaster strikes back
Hi, While porting Michael Elkins's ntile() implementation to 5.4.1, I noticed that it is actually shorter than vanilla tile()! It would however be useless without the setnmaster() function clocking in at 13 LOC, same as setmfact(). But the two have most of their code in common: 1. Verify layout != floating 2. Verify arg is within bounds 3. Set global variable (relatively or absolutely) 4. Call arrange() How about: enum { Abs, Rel }; void tweak(int *var, const int *val, int min, int max) { int i; i = val[1] + (val[0] == Abs ? 0 : *var); if(!lt[sellt]->arrange || i < min || i > max) return; *var = i; arrange(); } Previously setmfact(): void tweakmwp(const Arg *arg) { tweak(&mwp, arg->v, 5, 95); } Previously setnmaster(): void tweakmn(const Arg *arg) { tweak(&mn, arg->v, 1, wh / (1 + 2 * borderpx)); } Configuration example: static int mwp = 55; /* master area width percentage [5..95] */ static int mn = 1; /* number of clients in master area */ [...] { MODKEY,XK_h, tweakmwp, {.v = (int[]){Rel, -10}} }, { MODKEY|ShiftMask, XK_n, tweakmn, {.v = (int[]){Abs, 2}} }, A complete patch to dwm.c and config.def.h is attached. LOC # (including the new mn feature) stays about the same if you account for the fact that more (but much smaller) functions are penalized by whitespace, braces, and forward declarations. Note that the patch is on top of my last two patches from the virtual keyboards thread. It also corrects a discrepancy between documentation and code: mfact was described as [0.05..0.95], but was actually [0.1..0.9]. Regards, Peter diff --git a/config.def.h b/config.def.h index 03dc235..230e701 100644 --- a/config.def.h +++ b/config.def.h @@ -26,7 +26,8 @@ static Rule rules[] = { }; /* layout(s) */ -static float mfact = 0.55; /* factor of master area size [0.05..0.95] */ +static int mwp = 55; /* master area width percentage [5..95] */ +static int mn = 1;/* number of clients in master area */ static Bool resizehints = True; /* False means respect size hints in tiled resizals */ static Layout layouts[] = { @@ -58,8 +59,10 @@ static Key keys[] = { { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, selstack, {.i = +1 } }, { MODKEY, XK_k, selstack, {.i = -1 } }, - { MODKEY, XK_h, setmfact, {.f = -0.05} }, - { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY, XK_h, tweakmwp, {.v = (int[]){Rel, -5}} }, + { MODKEY, XK_l, tweakmwp, {.v = (int[]){Rel, +5}} }, + { MODKEY|ShiftMask, XK_h, tweakmn,{.v = (int[]){Rel, -1}} }, + { MODKEY|ShiftMask, XK_l, tweakmn,{.v = (int[]){Rel, +1}} }, { MODKEY, XK_Return, zoom, {0} }, { MODKEY, XK_Tab,view, {0} }, { MODKEY|ShiftMask, XK_c, killclient, {0} }, diff --git a/dwm.c b/dwm.c index 0557143..ad1886d 100644 --- a/dwm.c +++ b/dwm.c @@ -56,6 +56,7 @@ #define TEXTW(x)(textnw(x, strlen(x)) + dc.font.height) /* enums */ +enum { Abs, Rel }; enum { CurNormal, CurResize, CurMove, CurLast };/* cursor */ enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ @@ -178,7 +179,6 @@ static void selclient(Client *c); static void selstack(const Arg *arg); static void setclientstate(Client *c, long state); static void setlayout(const Arg *arg); -static void setmfact(const Arg *arg); static void setup(void); static void showhide(Client *c, unsigned int ntiled); static void sigchld(int signal); @@ -186,10 +186,14 @@ static void spawn(const Arg *arg); static void tag(const Arg *arg); static int textnw(const char *text, unsigned int len); static void tile(void); +static Client *tilecolumn(Client* c, unsigned int n, unsigned int nt, int x, int y, int w, int h, unsigned int *maxw); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); +static void tweak(int *var, const int *val, int min, int max); +static void tweakmwp(const Arg *arg); +static void tweakmn(const Arg *arg); static void unmanage(Client *c); static void unmapnotify(XEvent *e); static void updatebar(void); @@ -1271,20 +1275,6 @@ setlayout(const Arg *arg) { drawbar(); } -/* arg > 1.
Re: [OT] OFFTOPIC (was: Re: [dwm] Bottom-posting and reply trimming (was: Bottom Stack Patch))
yeah thank you too. Next time I will include the [sarcasm] tag for you... On 2/10/09, Enno Gottox Boland wrote: > don't introduce totally senseless rules noone respects. > > btw stfu. :) > > thanks. > > Gottox > > 2009/2/10, hiro <23h...@googlemail.com>: >> how about that? >> >> On 2/10/09, markus schnalke wrote: >> > [2009-02-10 06:51] Kurt H Maier >> >> >> >> Please mark mailing-list etiquette posts as off-topic, so my mail >> >> client and filter them appropriately. Thanks. >> > >> > Can you please tell me how to do so. >> > >> > I know people who use ... . Do you mean that? >> > >> > >> > meillo >> > >> >> > > > -- > http://www.gnuffy.org - Real Community Distro > http://www.gnuffy.org/index.php/GnuEm - Gnuffy on Ipaq (Codename Peggy) > >
Re: [OT] OFFTOPIC (was: Re: [dwm] Bottom-posting and reply trimming (was: Bottom Stack Patch))
don't introduce totally senseless rules noone respects. btw stfu. :) thanks. Gottox 2009/2/10, hiro <23h...@googlemail.com>: > how about that? > > On 2/10/09, markus schnalke wrote: > > [2009-02-10 06:51] Kurt H Maier > >> > >> Please mark mailing-list etiquette posts as off-topic, so my mail > >> client and filter them appropriately. Thanks. > > > > Can you please tell me how to do so. > > > > I know people who use ... . Do you mean that? > > > > > > meillo > > > > -- http://www.gnuffy.org - Real Community Distro http://www.gnuffy.org/index.php/GnuEm - Gnuffy on Ipaq (Codename Peggy)
[OT] OFFTOPIC (was: Re: [dwm] Bottom-posting and reply trimming (was: Bottom Stack Patch))
how about that? On 2/10/09, markus schnalke wrote: > [2009-02-10 06:51] Kurt H Maier >> >> Please mark mailing-list etiquette posts as off-topic, so my mail >> client and filter them appropriately. Thanks. > > Can you please tell me how to do so. > > I know people who use ... . Do you mean that? > > > meillo >
Re: [dwm] dwm for win32 - bug.n NEW version (3.5)
Am Sat, 7 Feb 2009 11:14:57 + schrieb "A.S. Bradbury" : > After soom googling, it appears that putty requires the > WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE messages[1] to bracket its > resizes. It seems this has been translated into AutoHotKey commands on > the forums[2]. Is there any chance you could add such a workaround for > putty? With your help it was easy - thank you. And so I did - version 3.5.1 ready to download. Please report any problems, since I just did basic tests with a portable version. Kind regards, joten
Re: [dwm] Bottom-posting and reply trimming (was: Bottom Stack Patch)
[2009-02-10 06:51] Kurt H Maier > > Please mark mailing-list etiquette posts as off-topic, so my mail > client and filter them appropriately. Thanks. Can you please tell me how to do so. I know people who use ... . Do you mean that? meillo signature.asc Description: Digital signature
Re: [dwm] OT: Bottom-posting and reply trimming (was: Bottom Stack Patch)
If I had done that, then nobody who filters off-topic mails would have seen that I had requested it. It was deliberately not marked off-topic to avoid more than one person feeling the need to request it. Thanks. # Kurt H Maier On Tue, Feb 10, 2009 at 7:42 AM, Premysl Hruby wrote: > On (10/02/09 06:51), Kurt H Maier wrote: >> To: dwm mail list >> From: Kurt H Maier >> Subject: Re: [dwm] Bottom-posting and reply trimming (was: Bottom Stack >> Patch) >> Reply-To: dwm mail list >> List-Id: dwm mail list >> >> Please mark mailing-list etiquette posts as off-topic, so my mail >> client and filter them appropriately. Thanks. >> >> # Kurt H Maier >> > > Why you want others to do something, which you don't do yourself. > > (Your email wasn't marked as OT) > > -Ph > > -- > Premysl "Anydot" Hruby, http://www.redrum.cz/ > >
Re: [dwm] OT: Bottom-posting and reply trimming (was: Bottom Stack Patch)
On (10/02/09 06:51), Kurt H Maier wrote: > To: dwm mail list > From: Kurt H Maier > Subject: Re: [dwm] Bottom-posting and reply trimming (was: Bottom Stack Patch) > Reply-To: dwm mail list > List-Id: dwm mail list > > Please mark mailing-list etiquette posts as off-topic, so my mail > client and filter them appropriately. Thanks. > > # Kurt H Maier > Why you want others to do something, which you don't do yourself. (Your email wasn't marked as OT) -Ph -- Premysl "Anydot" Hruby, http://www.redrum.cz/
Re: [dwm] Bottom-posting and reply trimming (was: Bottom Stack Patch)
Please mark mailing-list etiquette posts as off-topic, so my mail client and filter them appropriately. Thanks. # Kurt H Maier On Mon, Feb 9, 2009 at 8:17 PM, Neale Pickett wrote: > Folks, > > May I suggest that you get into the habit of trimming your replies? > This is more important for bottom-posting, where your reply goes after > the quoted text. Scrolling up and down to follow the conversation in > the "Bottom Stack Patch" thread was mildly annoying :) > > That's all, thanks for your attention. > > Neale > >
Re: [dwm] Re: stdin to statusbar output removed?
2009/2/10 Valentin : > http://sprunge.us/VKeN?c http://sprunge.us/VKeN For your wget-ing/copy and paste pleasure. -- Samuel 'Shardz' Baldwin - staticfree.info/~samuel/
Re: [dwm] Re: stdin to statusbar output removed?
Simplified: dwmstat & exec dwm http://sprunge.us/VKeN?c Uses a bit less resources than xsetroot ;) On Tue, 10 Feb 2009 11:53:29 +0100 "Enno \"Gottox\" Boland" wrote: > simplified: > > while xsetroot -name "`date` `uptime | sed 's/.*,//'`"; do >sleep 1 > done & > exec dwm > > 2009/2/10, Pavel Samek : > > Neale Pickett writes: > > > > > > > > http://thread.gmane.org/gmane.comp.window-managers.dwm/6874 > > > > > > > > > Yes! And here is also a hint how to make Xsession exitting when dwm > > finishes. The README should be corrected I thing: > > > > while true > > do > > xsetroot -name "`date` `uptime | sed 's/.*,//'`" || exit 0 > > sleep 1 > > done & > > exec dwm > > > > > > Pavel. > > > > > > > > --
Re: [dwm] Re: stdin to statusbar output removed?
simplified: while xsetroot -name "`date` `uptime | sed 's/.*,//'`"; do sleep 1 done & exec dwm 2009/2/10, Pavel Samek : > Neale Pickett writes: > > > > > http://thread.gmane.org/gmane.comp.window-managers.dwm/6874 > > > > > Yes! And here is also a hint how to make Xsession exitting when dwm finishes. > The README should be corrected I thing: > > while true > do > xsetroot -name "`date` `uptime | sed 's/.*,//'`" || exit 0 > sleep 1 > done & > exec dwm > > > Pavel. > > > -- http://www.gnuffy.org - Real Community Distro http://www.gnuffy.org/index.php/GnuEm - Gnuffy on Ipaq (Codename Peggy)
Re: [dwm] stdin to statusbar output removed?
On 2/10/09, Neale Pickett wrote: > http://thread.gmane.org/gmane.comp.window-managers.dwm/6874 > > And here Anselm announces it's going in: > >http://thread.gmane.org/gmane.comp.window-managers.dwm/6924 fyi we have perfectly nice list archives: http://lists.suckless.org/dwm/ and the relevant thread: http://lists.suckless.org/dwm/0812/7098.html
[dwm] Re: stdin to statusbar output removed?
Neale Pickett writes: > > http://thread.gmane.org/gmane.comp.window-managers.dwm/6874 > Yes! And here is also a hint how to make Xsession exitting when dwm finishes. The README should be corrected I thing: while true do xsetroot -name "`date` `uptime | sed 's/.*,//'`" || exit 0 sleep 1 done & exec dwm Pavel.