{ MODKEY, XK_g, spawn, {.v = getmail} },
{ MODKEY, XK_x, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_l, spawn, {.v = lockcmd } },
- { MODKEY, XK_e, findemacs, {0} },
+ { MODKEY, XK_e, findwindow, {.v= "Emacs"} },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
static void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
static void enternotify(XEvent *e);
static void expose(XEvent *e);
-static void findemacs(const Arg *arg);
+static void findwindow(const Arg *arg);
static void focus(Client *c);
static void focusin(XEvent *e);
static void focusmon(const Arg *arg);
}
void
-findemacs (const Arg *arg) {
+findwindow (const Arg *arg) {
/* Tries to find an emacs instance. If it finds one,
it displays it. */
Arg a;
Monitor *m;
Client *c;
+ XClassHint ch = { NULL, NULL};
+ const char *class ;
for (m=mons; m; m = m->next)
- for (c=m->clients; c; c=c->next)
- if (strspn("emacs",c->name)) {
- a.ui = c->tags;
- view(&a);
- unfocus(selmon->sel, True); /* this should focus the right monitor (not tested)*/
- selmon = m;
- focus(c);
- restack(selmon);
- return;
- }
+ for (c=m->clients; c; c=c->next) {
+ XGetClassHint(dpy, c->win, &ch);
+ class = ch.res_class ? ch.res_class : broken;
+ if (strstr(class,(char*)arg->v)) {
+ a.ui = c->tags;
+ view(&a);
+ unfocus(selmon->sel, True); /* this should focus the right monitor (not tested)*/
+ selmon = m;
+ focus(c);
+ restack(selmon);
+ if(ch.res_class)
+ XFree(ch.res_class);
+ if(ch.res_name)
+ XFree(ch.res_name);
+ return;
+ }
+ }
}
void