On 12:34 Thu 04 Jun , Jeremy Jay wrote: > On Thu 04 Jun 2009 - 03:55PM, [email protected] wrote: > > On 16:07 Thu 04 Jun , pancake wrote: > > > isn't meta-0 the exposee you are looking for? didnt check your patch but > > > I prefer not to depend on composite or gl extensions that never work fine > > > > Thanks, but meta-0 is not what I am looking for; when I have a cluttered > > X session: > > 1) I can't actually see much of the individual windows > > 2) Any floating windows (gimp etc.) occlude the windows underneath > > 3) Selecting and jumping to one of the windows is a pain > > I must be missing something here.... You're using dwm, but you're using > the tags as virtual screens instead of tags? The whole point of tiling > window managers like dwm is that you don't have to do window management > (ie expose-like features)... If you have too many windows on your tags, > add more tags! If you can't find a window then you're doing it wrong. > > I suggest kicking your virtual-screen habits and using it as it was > intended, you'll save yourself a lot of time and effort. > > Jeremy
I think the main problem is that dwm cannot dynamically adjust the number/name of tags. I find it very hard to keep track of the number->application/task mapping in my head. I could change the names of the tags to meaningful names, but then I would end up with task(s) that have no corresponding tag - and I'm back to confusion. I have therefore implemented a patch to allow tags names to be changed dynamically. It basically allows commands to be sent to dwm by setting the DWM_COMMAND Property on the root window (in the same way that the status text works), the first letter of the string is the command. Currently only N is recognised, and changes the name of all the selected tags to n(<str>) where n is the tag number, and str is the remainder of the command string. I could not find a small shell program that could change a named property of the root window, so wrote my own (also attached). Example usage: xsetatom DWM_COMMAND NWork-dwm with tag 2 selected would cause tag two's name to become '2(Work-dwm)'. Setting the command to just N will cause the names of the selected tags to revert to just numbers. I have a nice little dmenu script so I can type in new tag names, and find it very useful. This patch allows other commands to be easily added (see runcommand()). Tom -- Thomas Spurden
/*
* Set an XAtom to a single text value.
* gcc xsetatom.c -lX11 -o xsetatom
*/
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv) {
Display* dpy;
Window root;
Atom atom;
XTextProperty prop;
if(argc < 3) {
printf("Usage: xsetatom <name> <value>\n");
exit(EXIT_FAILURE);
}
dpy = XOpenDisplay(0);
if(dpy == None) {
fprintf(stderr, "Could not open display\n");
exit(EXIT_FAILURE);
}
root = DefaultRootWindow(dpy);
atom = XInternAtom(dpy, argv[1], False);
XStringListToTextProperty(&argv[2], 1, &prop);
XSetTextProperty(dpy, root, &prop, atom);
XSync(dpy, False);
XCloseDisplay(dpy);
exit(EXIT_SUCCESS);
}
diff -r 440dda47ae5b config.def.h
--- a/config.def.h Fri May 29 09:29:22 2009 +0100
+++ b/config.def.h Fri Jun 05 13:16:51 2009 +0100
@@ -14,7 +14,7 @@
static Bool topbar = True; /* False means bottom bar */
/* tagging */
-static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+static char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9"
};
static unsigned int tagset[] = {1, 1}; /* after start, first tag is selected */
static Rule rules[] = {
diff -r 440dda47ae5b dwm.c
--- a/dwm.c Fri May 29 09:29:22 2009 +0100
+++ b/dwm.c Fri Jun 05 13:16:51 2009 +0100
@@ -54,6 +54,8 @@
#define TAGMASK ((int)((1LL << LENGTH(tags)) - 1))
#define TEXTW(x) (textnw(x, strlen(x)) + dc.font.height)
+#define MAXTAGLEN 64
+
/* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
@@ -202,6 +204,7 @@
static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
+static void runcommand(void);
/* variables */
static char stext[256];
@@ -226,7 +229,7 @@
[PropertyNotify] = propertynotify,
[UnmapNotify] = unmapnotify
};
-static Atom wmatom[WMLast], netatom[NetLast];
+static Atom wmatom[WMLast], netatom[NetLast], commandatom;
static Bool otherwm;
static Bool running = True;
static Client *clients = NULL;
@@ -1063,8 +1066,13 @@
Window trans;
XPropertyEvent *ev = &e->xproperty;
- if((ev->window == root) && (ev->atom == XA_WM_NAME))
- updatestatus();
+ if(ev->window == root) {
+ if (ev->atom == XA_WM_NAME) {
+ updatestatus();
+ } else if(ev->atom == commandatom) {
+ runcommand();
+ }
+ }
else if(ev->state == PropertyDelete)
return; /* ignore */
else if((c = getclient(ev->window))) {
@@ -1279,6 +1287,7 @@
wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
+ commandatom = XInternAtom(dpy, "DWM_COMMAND", False);
/* init cursors */
wa.cursor = cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
@@ -1614,6 +1623,45 @@
}
void
+runcommand(void) {
+ char cmd[256];
+ if(!gettextprop(root, commandatom, cmd, sizeof(cmd))) {
+ /* Ignore empty commands, also prevents infinite loop */
+ return;
+ }
+ switch(cmd[0]) {
+ case 'N':
+ {
+ unsigned int ts = tagset[seltags];
+ unsigned int i;
+ for(i = 0; ts != 0; i++, ts >>= 1) {
+ if(ts & 1) {
+ if(cmd[1] == '\0') {
+ snprintf(tags[i],
MAXTAGLEN, "%u", i);
+ } else {
+ snprintf(tags[i],
MAXTAGLEN, "%u(%s)", i, cmd + 1);
+ }
+ }
+ }
+ drawbar();
+ }
+ break;
+ default:
+ fprintf(stderr, "dwm: Unknown command '%c'\n", cmd[0]);
+ break;
+ }
+ { /* Clear the command */
+ XTextProperty prop = {
+ .value = NULL,
+ .encoding = XA_STRING,
+ .format = 8,
+ .nitems = 0
+ };
+ XSetTextProperty(dpy, root, &prop, commandatom);
+ }
+}
+
+void
updatewmhints(Client *c) {
XWMHints *wmh;
pgppj7KRej94y.pgp
Description: PGP signature
