Commits

Anonymous committed 9e14940

neue bevor ich rumspiele

Comments (0)

Files changed (3)

 static const char selbordercolor[]  = "#a2cd5a";
 static const char selbgcolor[]      = "#151515";
 static const char selfgcolor[]      = "#ffffff";
-static const unsigned int borderpx  = 1;        /* border pixel of windows */
+static const unsigned int borderpx  = 2;        /* 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 int nmaster            = 2;
 
 /* tagging */
 static const char *tags[] = { "main", "web", "less", "edit", "tv"};
 static const Rule rules[] = {
     /* class      instance    title       tags mask     isfloating   monitor */
     { "Gimp",     NULL,       NULL,       0,            True,        -1 },
+    { NULL,         NULL,       "ncmpcpp",       0,            True,        -1 },
     { "Shiretoko",  NULL,        NULL,       1<<1,            False,       -1 },
     { "Gvim",  NULL,        NULL,       1<<3,            False,       -1 },
+    //{ NULL,  NULL,        NULL,       1<<3,            False,       -1 },
+    { "xvim",  NULL,        NULL,       1<<3,            False,       -1 },
     { NULL,  NULL,        "Gvim",       1<<3,            False,       -1 },
     { "Kaffeine",  NULL,        NULL,      1<<4,            False,       -1 },
-    { "Mplayer",  NULL,        NULL,       1<<4,            False,       -1 },
+    { "MPlayer",  NULL,        NULL,       1<<4,            False,       -1 },
     { NULL,         NULL,        "bashrun",       0,            True,       -1 },
-    { NULL,         NULL,        "Crack",       0,            True,       -1 },
+    { NULL,         NULL,        "Crack Attack",       0,            True,       -1 },
+    { "SWT",         NULL,        NULL,       1<<2,            True,       -1 },
+    { "alsamixer",         NULL,        NULL,       1<<1,            False,       -1 },
 };
 
-#include <functions.c>
+#include <functions.h>
+#include <nmaster.c>
 
 /* layout(s) */
-static const float mfact      = 0.66; /* factor of master area size [0.05..0.95] */
+static const float mfact      = 0.62; /* factor of master area size [0.05..0.95] */
 static const Bool resizehints = False; /* True means respect size hints in tiled resizals */
 
 static const Layout layouts[] = {
 	/* symbol     arrange function */
 	{ "[]=",      tile },    /* first entry is default */
+	{ "[M]",      monocle },
 	{ "><>",      NULL },    /* no layout function means floating behavior */
-	{ "[M]",      monocle },
 };
 
 /* key definitions */
 #define MODKEY Mod1Mask
 #define TAGKEYS(KEY,TAG) \
 { MODKEY,                       KEY,      view,           {.ui = 1 << TAG} }, \
-{ MODKEY|ShiftMask,             KEY,      toggleview,     {.ui = 1 << TAG} }, \
-{ MODKEY|ControlMask,           KEY,      tag,            {.ui = 1 << TAG} }, \
-{ Mod4Mask|ShiftMask,           KEY,      toggletag,      {.ui = 1 << TAG} }, \
+{ MODKEY|ControlMask,             KEY,      toggleview,     {.ui = 1 << TAG} }, \
+{ MODKEY|Mod4Mask,           KEY,      tag,            {.ui = 1 << TAG} }, \
+{ MODKEY|ShiftMask,             KEY,      toggletag,      {.ui = 1 << TAG} }, \
 { Mod4Mask,                     KEY,      tagandview,     {.ui = 1 << TAG} }, \
 
 #define MONKEYS(KEY,TAG) \
 { MODKEY,                       KEY,      viewmon,           {.ui = 1 << TAG} }, \
-{ MODKEY|Mod4Mask,                     KEY,      tagnextmon,        {.ui = 1 << TAG} }, \
-{ Mod4Mask,              KEY,      tagviewnextmon,    {.ui = 1 << TAG} }, \
+{ MODKEY|Mod4Mask,              KEY,      tagnextmon,        {.ui = 1 << TAG} }, \
+{ Mod4Mask,                     KEY,      tagviewnextmon,    {.ui = 1 << TAG} }, \
 
+#define FKEYS(KEY,TAG) \
+{ MODKEY,           KEY,      viewall,     {.ui = 1 << TAG} }, \
 /* helper for spawning shell commands in the pre dwm-5.0 fashion */
 #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
 
     { MODKEY,                     XK_Tab,    view,           {0} },
     { MODKEY,                       XK_c,      killclient,     {0} },
     { MODKEY,                       XK_d,      setlayout,      {.v = &layouts[0]} },
-    { MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
-    { MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
+    { MODKEY,                       XK_m,      setlayout,      {.v = &layouts[1]} },
+    { MODKEY,                       XK_f,      setlayout,      {.v = &layouts[2]} },
     { MODKEY,                       XK_space,  setlayout,      {0} },
     { MODKEY|Mod4Mask,             XK_space,  togglefloating, {0} },
+    { Mod4Mask,                     XK_j,  pushdown, {0} },
+    { Mod4Mask,                     XK_k,  pushup, {0} },
     { MODKEY,                       XK_0,      view,           {.ui = ~0 } },
     { Mod4Mask,                     XK_0,      tag,            {.ui = ~0 } },
     { Mod4Mask,                       XK_space,      focusmon,       {.i = +1 } },
+    { MODKEY,                     XK_h,      focusmon,         {.i = -1 } },
+    { MODKEY,                     XK_l,      focusmon,         {.i = +1 } },
     { Mod4Mask,                     XK_h,      tagmon,         {.i = -1 } },
     { Mod4Mask,                     XK_l,      tagmon,         {.i = +1 } },
     TAGKEYS(                        XK_1,                      0)
     MONKEYS(                        XK_e,                      2)
     MONKEYS(                        XK_r,                      3)
     MONKEYS(                        XK_t,                      4)
+    FKEYS(                        XK_F1,                      0)
+    FKEYS(                        XK_F2,                      1)
+    FKEYS(                        XK_F3,                      2)
+    FKEYS(                        XK_F4,                      3)
+    FKEYS(                        XK_F5,                      4)
         { MODKEY|ShiftMask,             XK_q,      quit,           {0} },
 };
 
     { ClkTagBar,            MODKEY,         Button1,        tag,            {0} },
     { ClkTagBar,            MODKEY,         Button3,        toggletag,      {0} },
 };
-
 	void (*arrange)(Monitor *);
 } Layout;
 
-struct Monitor {
-	char ltsymbol[16];
-	float mfact;
-	int num;
-	int by;               /* bar geometry */
-	int mx, my, mw, mh;   /* screen size */
-	int wx, wy, ww, wh;   /* window area  */
-	unsigned int seltags;
-	unsigned int sellt;
-	unsigned int tagset[2];
-	Bool showbar;
-	Bool topbar;
-	Client *clients;
-	Client *sel;
-	Client *stack;
-	Monitor *next;
-	Window barwin;
-	const Layout *lt[2];
-};
-
 typedef struct {
 	const char *class;
 	const char *instance;
 /* configuration, allows nested code to access above variables */
 #include "config.h"
 
+struct Monitor {
+	char ltsymbol[16];
+	float mfact;
+	int num;
+	int by;               /* bar geometry */
+	int mx, my, mw, mh;   /* screen size */
+	int wx, wy, ww, wh;   /* window area  */
+	unsigned int seltags;
+	unsigned int sellt;
+	unsigned int tagset[2];
+	Bool showbar;
+	Bool topbar;
+	Client *clients;
+	Client *sel;
+	Client *stack;
+	Monitor *next;
+	Window barwin;
+	const Layout *lt[2];
+	int curtag;
+	int prevtag;
+	const Layout *lts[LENGTH(tags) + 1];
+	double mfacts[LENGTH(tags) + 1];
+	Bool showbars[LENGTH(tags) + 1];
+};
+
+#include <functions.c>
 /* compile-time check if all tags fit into an unsigned int bit array. */
 struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
 
 	int x;
 	unsigned int i, occ = 0, urg = 0;
 	unsigned long *col;
+    char mf[4];
+
 	Client *c;
 
+    sprintf(mf, "%.2f", selmon->mfacts[selmon->curtag]); 
 	for(c = m->clients; c; c = c->next) {
 		occ |= c->tags;
 		if(c->isurgent)
 	drawtext(m->ltsymbol, dc.norm, False);
 	dc.x += dc.w;
 	x = dc.x;
+    dc.w = TEXTW(mf);
+	drawtext(mf, dc.norm, False);
+	dc.x += dc.w;
+	x = dc.x;
 	if(m == selmon) { /* status is only drawn on selected monitor */
 		dc.w = TEXTW(stext);
 		dc.x = m->ww - dc.w;
 	if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
 		selmon->sellt ^= 1;
 	if(arg && arg->v)
-		selmon->lt[selmon->sellt] = (Layout *)arg->v;
+		selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag] = (Layout *)arg->v;
 	strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
 	if(selmon->sel)
 		arrange(selmon);
 	f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
 	if(f < 0.1 || f > 0.9)
 		return;
-	selmon->mfact = f;
+	selmon->mfact = selmon->mfacts[selmon->curtag] =  f;
 	arrange(selmon);
 }
 
 void
 setup(void) {
 	XSetWindowAttributes wa;
+	Monitor *m;
+	unsigned int i;
 
 	/* clean up any zombies immediately */
 	sigchld(0);
 	XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
 	if(!dc.font.set)
 		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
+	/* init tags */
+	for(m = mons; m; m = m->next)
+		m->curtag = m->prevtag = 1;
+	/* init mfacts */
+	for(m = mons; m; m = m->next) {
+		for(i=0; i < LENGTH(tags) + 1 ; i++) {
+			m->mfacts[i] = m->mfact;
+		}
+	}
+	/* init layouts */
+	for(m = mons; m; m = m->next) {
+		for(i=0; i < LENGTH(tags) + 1; i++) {
+			m->lts[i] = &layouts[0];
+		}
+	}
 	/* init bars */
+	for(m = mons; m; m = m->next) {
+		for(i=0; i < LENGTH(tags) + 1; i++) {
+			m->showbars[i] = m->showbar;
+		}
+	}
 	updatebars();
 	updatestatus();
 	/* EWMH support per view */
 tag(const Arg *arg) {
 	if(selmon->sel && arg->ui & TAGMASK) {
 		selmon->sel->tags = arg->ui & TAGMASK;
+        if(selmon->showbar != selmon->showbars[selmon->curtag])
+            togglebar(NULL);
 		arrange(selmon);
 	}
 }
 
 void
 togglebar(const Arg *arg) {
-	selmon->showbar = !selmon->showbar;
+	selmon->showbar = selmon->showbars[selmon->curtag] = !selmon->showbar;
 	updatebarpos(selmon);
 	XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
 	arrange(selmon);
 void
 toggletag(const Arg *arg) {
 	unsigned int newtags;
+	unsigned int i;
 
 	if(!selmon->sel)
 		return;
 	newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
 	if(newtags) {
 		selmon->sel->tags = newtags;
+		if(newtags == ~0) {
+			selmon->prevtag = selmon->curtag;
+			selmon->curtag = 0;
+		}
+		if(!(newtags & 1 << (selmon->curtag - 1))) {
+			selmon->prevtag = selmon->curtag;
+			for (i=0; !(newtags & 1 << i); i++);
+			selmon->curtag = i + 1;
+		}
+		selmon->sel->tags = newtags;
+		selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
+		selmon->mfact = selmon->mfacts[selmon->curtag];
+		if (selmon->showbar != selmon->showbars[selmon->curtag])
+			togglebar(NULL);
 		arrange(selmon);
 	}
 }
 
 void
 view(const Arg *arg) {
+	unsigned int i;
+
 	if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
 		return;
 	selmon->seltags ^= 1; /* toggle sel tagset */
-	if(arg->ui & TAGMASK)
+	if(arg->ui & TAGMASK) {
 		selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+		selmon->prevtag = selmon->curtag;
+		if(arg->ui == ~0)
+			selmon->curtag = 0;
+		else {
+			for (i=0; !(arg->ui & 1 << i); i++);
+			selmon->curtag = i + 1;
+		}
+	} else {
+		selmon->prevtag= selmon->curtag ^ selmon->prevtag;
+		selmon->curtag^= selmon->prevtag;
+		selmon->prevtag= selmon->curtag ^ selmon->prevtag;
+	}
+	selmon->lt[selmon->sellt]= selmon->lts[selmon->curtag];
+	selmon->mfact = selmon->mfacts[selmon->curtag];
+	if(selmon->showbar != selmon->showbars[selmon->curtag])
+		togglebar(NULL);
 	arrange(selmon);
 }
 
-static void tagandview(const Arg *arg);
-static void tagnextmon(const Arg *arg);
-static void viewmon(const Arg *arg);
-
 void
 tagandview(const Arg *arg) {
 	if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
 	selmon->seltags ^= 1; /* toggle sel tagset */
 	if(selmon->sel && arg->ui & TAGMASK) 
 		selmon->tagset[selmon->seltags] = selmon->sel->tags = arg->ui & TAGMASK;
+	if(selmon->showbar != selmon->showbars[selmon->curtag])
+		togglebar(NULL);
 	arrange(selmon);
 }
 
     focus(c);
     arrange(m);
 }
+static Client *
+prevtiled(Client *c) {
+	Client *p, *r;
+
+	for(p = selmon->clients, r = NULL; p && p != c; p = p->next)
+		if(!p->isfloating && ISVISIBLE(p))
+			r = p;
+	return r;
+}
+
+static void
+pushup(const Arg *arg) {
+	Client *sel = selmon->sel;
+	Client *c;
+
+	if(!sel || sel->isfloating)
+		return;
+	if((c = prevtiled(sel))) {
+		/* attach before c */
+		detach(sel);
+		sel->next = c;
+		if(selmon->clients == c)
+			selmon->clients = sel;
+		else {
+			for(c = selmon->clients; c->next != sel->next; c = c->next);
+			c->next = sel;
+		}
+	} else {
+		/* move to the end */
+		for(c = sel; c->next; c = c->next);
+		detach(sel);
+		sel->next = NULL;
+		c->next = sel;
+	}
+	focus(sel);
+	arrange(selmon);
+}
+
+static void
+pushdown(const Arg *arg) {
+	Client *sel = selmon->sel;
+	Client *c;
+
+	if(!sel || sel->isfloating)
+		return;
+	if((c = nexttiled(sel->next))) {
+		detach(sel);
+		sel->next = c->next;
+		c->next = sel;
+	} else {
+		detach(sel);
+		attach(sel);
+	}
+	focus(sel);
+	arrange(selmon);
+}
+static void
+viewall(const Arg *arg) {
+	unsigned int i;
+    Monitor *m; 
+
+    if (!mons->next) {
+        return;
+    }
+
+    for(m=mons; m; m=m->next) {
+        if((arg->ui & TAGMASK) != m->tagset[m->seltags]) {
+            m->seltags ^= 1; 
+            if(arg->ui & TAGMASK) {
+                m->tagset[m->seltags] = arg->ui & TAGMASK;
+                m->prevtag = m->curtag;
+                if(arg->ui == ~0)
+                    m->curtag = 0;
+                else {
+                    for (i=0; !(arg->ui & 1 << i); i++);
+                    m->curtag = i + 1;
+                }
+            } else {
+                m->prevtag= m->curtag ^ m->prevtag;
+                m->curtag^= m->prevtag;
+                m->prevtag= m->curtag ^ m->prevtag;
+            }
+            m->lt[m->sellt]= m->lts[m->curtag];
+            m->mfact = m->mfacts[m->curtag];
+            if(m->showbar != m->showbars[m->curtag])
+                togglebar(NULL);
+            arrange(m);
+        }
+    }
+}
+