From: Marco Peereboom Date: Thu, 23 Jun 2011 18:56:39 +0000 (+0000) Subject: Make layout fancier by adding master_grow, master_shrink, master_add, X-Git-Url: https://jasonwoof.com/gitweb/?a=commitdiff_plain;h=014589e60503fee99276da4252258e553d62b055;p=spectrwm.git Make layout fancier by adding master_grow, master_shrink, master_add, master_del, stack_inc and stack_del to the format string. --- diff --git a/scrotwm.1 b/scrotwm.1 index 9640322..07a3c25 100644 --- a/scrotwm.1 +++ b/scrotwm.1 @@ -122,14 +122,30 @@ This ratio is the screen size to what they will be resized. For example, 0.6 is 60% of the physical screen size. .It Cm layout select layout to use at start-of-day. -Defined in the format ws[]:, e.g. ws[2]:horizontal sets worskspace -2 to the horizontal stack mode. -This setting is not retained at restart. -Possible values are +Defined in the format ws[idx]:master_grow:master_add:stack_inc:layout, e.g. +ws[2]:-4:0:1:horizontal sets worskspace 2 to the horizontal stack mode and +shrinks the master area by 4 ticks and adds one window to the stack. +Possible layout values are .Pa vertical , .Pa horizontal and .Pa fullscreen . +.Pp +See +.Pa master_grow , +.Pa master_shrink , +.Pa master_add , +.Pa master_del , +.Pa stack_inc , +and +.Pa stack_del +for more information. +Note that the stacking options are complicated and have side-effects. +One should familiarize oneself with these commands before experimenting with the +.Pa layout +option. +.Pp +This setting is not retained at restart. .It Cm region Allocates a custom region, removing any autodetected regions which occupy the same space on the screen. diff --git a/scrotwm.c b/scrotwm.c index a1f1c0a..3b7bfce 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -4589,7 +4589,7 @@ setautorun(char *selector, char *value, int flags) int setlayout(char *selector, char *value, int flags) { - int ws_id, st, i; + int ws_id, st, i, x, mg, ma, si; char s[1024]; struct workspace *ws; @@ -4597,7 +4597,8 @@ setlayout(char *selector, char *value, int flags) return (0); bzero(s, sizeof s); - if (sscanf(value, "ws[%d]:%1023c", &ws_id, s) != 2) + if (sscanf(value, "ws[%d]:%d:%d:%d:%1023c", + &ws_id, &mg, &ma, &si, s) != 5) errx(1, "invalid layout entry, should be 'ws[]:'\n"); ws_id--; if (ws_id < 0 || ws_id >= SWM_WS_MAX) @@ -4615,6 +4616,30 @@ setlayout(char *selector, char *value, int flags) for (i = 0; i < ScreenCount(display); i++) { ws = (struct workspace *)&screens[i].ws; ws[ws_id].cur_layout = &layouts[st]; + if (st == SWM_MAX_STACK) + continue; + + /* master grow */ + for (x = 0; x < abs(mg); x++) { + ws[ws_id].cur_layout->l_config(&ws[ws_id], + mg >= 0 ? SWM_ARG_ID_MASTERGROW : + SWM_ARG_ID_MASTERSHRINK); + stack(); + } + /* master add */ + for (x = 0; x < abs(ma); x++) { + ws[ws_id].cur_layout->l_config(&ws[ws_id], + ma >= 0 ? SWM_ARG_ID_MASTERADD : + SWM_ARG_ID_MASTERDEL); + stack(); + } + /* stack inc */ + for (x = 0; x < abs(si); x++) { + ws[ws_id].cur_layout->l_config(&ws[ws_id], + si >= 0 ? SWM_ARG_ID_STACKINC : + SWM_ARG_ID_STACKDEC); + stack(); + } } return (0); diff --git a/scrotwm.conf b/scrotwm.conf index 09741b5..f10abc5 100644 --- a/scrotwm.conf +++ b/scrotwm.conf @@ -46,9 +46,9 @@ dialog_ratio = 0.6 # autorun = ws[2]:xxxterm http://www.openbsd.org # workspace layout -# layout = ws[1]:vertical -# layout = ws[2]:horizontal -# layout = ws[3]:fullscreen +# layout = ws[1]:4:0:0:vertical +# layout = ws[2]:0:0:0:horizontal +# layout = ws[3]:0:0:0:fullscreen # mod key, (windows key is Mod4) (apple key on OSX is Mod2) # modkey = Mod1