hello,

if you were referring to dwm rather than wmii...

On Mon, Jun 06, 2011 at 02:49:57PM +0100, Piotr Zalewa wrote:
> >>I want to create a script which will load my default setup (quite a
> >>few programs).
> >
> >I use .xinitrc for this.

... or .xsession

> I don't want to do it every time

then create a script that launches your programs and launch that script
from an xterm, dmenu or a shortcut in your dwm.h

> >>How to run a program so it will be displayed on a desired tab? (view,
> >>workspace - I always had a problem with that lingo)
> >
> >I assign programs to tags in config.h.
> 
> It's more complicated as xterms are on many tags

it is still the right way to do what you ask for with dwm and anyway
it's the only way at least with a stock dwm.

as others suggested, you can match on several properties in rules[] in
config.h and they are not difficult to set from the command line for
your xterms.

one annoyance with the whole dwm concept is that you have to restart dwm
to try new rules, since you need to recompile.

with attached respawn.patch patch, you won't need to exit your X
session, rather dwm will respawn over itself - but with the new version
of itself as found on disk. of course if the new version crashes your X
session will terminate and if it does not work somehow, you may have to
forcibly terminate it, but if your changes are sane, you will be fine,
and anyway, hey, you have to try out the new build at some point (one
alternative being to try the new build in a nested X server such as
xephyr+xoo).

if you are interested in the respawn patch, then you will find that when
dwm starts in lieu of any other WM, including itself, all clients for
which there is no rule move to the 1st tag.

attached remember_tags.patch will solve that problem by recording tags
in an xprop for each X client, which is remembered through dwm restarts.

note: these are patches from a mercurial queue over my dwm repo, not
revisions against the dwm repo itself. apply them as unversioned diffs
or import them into your own mercurial queue and then "hg qpush" them.

most likely you found out that you don't want to install to /usr/bin/dwm
nor /usr/local/bin/dwm everytime you edit your config.h so you probably
have your own makefile variant that will install to ~/bin or something.
if you don't, well, i have a patch for that but it's a bit convoluted
due to supporting install over the same home directory for multiple
machines with different architectures, so i am not providing _that_ part
of my patch queue at this time.

cheers

-- 
Benoit Triquet <benoit.triquet at gmail.com>
 .''`.
: :' :      We are debian.org. Lower your prices, surrender your code.
`. `'       We will add your hardware and software distinctiveness to
  `-        our own. Resistance is futile.
diff -r c19e2f20ca69 config.def.h
--- a/config.def.h	Thu Oct 29 15:39:12 2009 +0100
+++ b/config.def.h	Thu Oct 29 15:43:42 2009 +0100
@@ -80,7 +80,8 @@
 	TAGKEYS(                        XK_7,                      6)
 	TAGKEYS(                        XK_8,                      7)
 	TAGKEYS(                        XK_9,                      8)
-	{ MODKEY|ShiftMask,             XK_q,      quit,           {0} },
+	{ MODKEY|ShiftMask|ControlMask, XK_q,      quit,           {.i = 0 } },
+	{ MODKEY|ShiftMask,             XK_q,      quit,           {.i = 1 } },
 };
 
 /* button definitions */
diff -r c19e2f20ca69 dwm.c
--- a/dwm.c	Thu Oct 29 15:39:12 2009 +0100
+++ b/dwm.c	Thu Oct 29 15:43:42 2009 +0100
@@ -270,6 +270,7 @@
 static Monitor *mons = NULL, *selmon = NULL;
 static Window root;
+static char **args;
 
 /* configuration, allows nested code to access above variables */
 #include "config.h"
 
@@ -1292,6 +1293,8 @@
 
 void
 quit(const Arg *arg) {
+	if(arg->i)	/* restart dwm, if fails just fall through and exit */
+		execv(args[0], args);
 	running = False;
 }
 
@@ -2008,6 +2011,7 @@
 		fputs("warning: no locale support\n", stderr);
 	if(!(dpy = XOpenDisplay(NULL)))
 		die("dwm: cannot open display\n");
+	args = argv;
 	checkotherwm();
 	setup();
 	scan();
# HG changeset patch
# Parent 3b5f9910413a84c53905b237e5fbf0728bb1081c

diff -r 3b5f9910413a dwm.c
--- a/dwm.c	Wed Oct 27 15:43:16 2010 +0200
+++ b/dwm.c	Wed Oct 27 15:46:10 2010 +0200
@@ -275,6 +275,7 @@
 static Monitor *mons = NULL, *selmon = NULL;
 static Window root;
 static char **args;
+static Atom dwmatom_tags;
 
 /* configuration, allows nested code to access above variables */
 #include "config.h"
@@ -1104,8 +1105,15 @@
 		c->tags = t->tags;
 	}
 	else {
+		Atom atom; int format; unsigned long n, extra; unsigned int *ptags;
 		c->mon = selmon;
-		applyrules(c);
+		if(XGetWindowProperty(dpy, w, dwmatom_tags, 0L, 1L, False, XA_CARDINAL,
+		  &atom, &format, &n, &extra, (unsigned char **)&ptags)==Success && n==1 && *ptags!=0)
+			c->tags = *ptags; /* override rule tags with memorized tags */
+		else {
+			applyrules(c);
+			XChangeProperty(dpy, w, dwmatom_tags, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&c->tags, 1);
+		}
 	}
 	/* geometry */
 	c->x = c->oldx = wa->x + c->mon->wx;
@@ -1534,6 +1542,7 @@
 	netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
 	netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);
 	netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
+	dwmatom_tags = XInternAtom(dpy, "DWM_TAGS", False);
 	/* init cursors */
 	cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
 	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
@@ -1607,6 +1616,7 @@
 tag(const Arg *arg) {
 	if(selmon->sel && arg->ui & TAGMASK) {
 		selmon->sel->tags = arg->ui & TAGMASK;
+		XChangeProperty(dpy, selmon->sel->win, dwmatom_tags, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&selmon->sel->tags, 1);
 		arrange(selmon);
 	}
 }
@@ -1687,6 +1697,7 @@
 	newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
 	if(newtags) {
 		selmon->sel->tags = newtags;
+		XChangeProperty(dpy, selmon->sel->win, dwmatom_tags, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&selmon->sel->tags, 1);
 		arrange(selmon);
 	}
 }

Reply via email to