I really wanted to use tabbed as a generic tool for tabbing any XNest-aware client, but the current code would require I have a seperately compiled version for each client (tabbed-surf, tabbed-xterm, etc) The attached patch is my solution. It allows an invocation like:
./tabbed xterm -into or ./tabbed surf -e -- Stephen Paul Weber, @singpolyma Please see <http://singpolyma.net> for how I prefer to be contacted. edition right joseph
diff -r f8f6841b3c1c config.def.h
--- a/config.def.h Mon Aug 09 11:59:13 2010 +0100
+++ b/config.def.h Thu Nov 04 11:52:46 2010 -0400
@@ -12,7 +12,7 @@
static Key keys[] = { \
/* modifier key function argument */
{ MODKEY|ShiftMask, XK_Return, focusonce, { 0 } },
- { MODKEY|ShiftMask, XK_Return, spawn, { .v = (char*[]){ "surf", "-e", winid, NULL} } },
+ { MODKEY|ShiftMask, XK_Return, spawn, { .v = NULL } },
{ MODKEY|ShiftMask, XK_l, rotate, { .i = +1 } },
{ MODKEY|ShiftMask, XK_h, rotate, { .i = -1 } },
{ MODKEY, XK_Tab, rotate, { .i = 0 } },
@@ -28,3 +28,8 @@
{ MODKEY, XK_0, move, { .i = 9 } },
{ MODKEY, XK_q, killclient, { 0 } },
};
+
+void
+setup_config(void) {
+ keys[1].arg.v = cmd;
+}
diff -r f8f6841b3c1c tabbed.c
--- a/tabbed.c Mon Aug 09 11:59:13 2010 +0100
+++ b/tabbed.c Thu Nov 04 11:52:46 2010 -0400
@@ -48,14 +48,14 @@
typedef union {
int i;
- const void *v;
+ void *v;
} Arg;
typedef struct {
unsigned int mod;
KeySym keysym;
void (*func)(const Arg *);
- const Arg arg;
+ Arg arg;
} Key;
typedef struct {
@@ -150,6 +150,7 @@
static Client *clients = NULL, *sel = NULL, *lastsel = NULL;
static int (*xerrorxlib)(Display *, XErrorEvent *);
static char winid[64];
+static char **cmd = NULL;
/* configuration, allows nested code to access above variables */
#include "config.h"
@@ -189,8 +190,8 @@
Client *c, *n;
for(c = clients; c; c = n) {
+ focus(c);
killclient(NULL);
- focus(c);
XReparentWindow(dpy, c->win, root, 0, 0);
n = c->next;
unmanage(c);
@@ -203,6 +204,7 @@
XFreeGC(dpy, dc.gc);
XDestroyWindow(dpy, win);
XSync(dpy, False);
+ free(cmd);
}
void
@@ -743,6 +745,7 @@
snprintf(winid, LENGTH(winid), "%u", (int)win);
nextfocus = foreground;
focus(clients);
+ setup_config();
}
void
@@ -842,16 +845,33 @@
return xerrorxlib(dpy, ee); /* may call exit */
}
+void
+set_cmd(int argc, char **argv) {
+ int i;
+ if(!(cmd = malloc((argc+2) * sizeof(*cmd)))) {
+ die("Error allocating memory.");
+ }
+ for(i = 0; i < argc; i++) {
+ cmd[i] = argv[i];
+ }
+ cmd[argc] = winid;
+ cmd[argc+1] = NULL;
+}
+
int
main(int argc, char *argv[]) {
int detach = 0;
- if(argc == 2 && !strcmp("-v", argv[1]))
+ if(argc > 1 && !strcmp("-v", argv[1])) {
die("tabbed-"VERSION", © 2009-2010 tabbed engineers, see LICENSE for details\n");
- else if(argc == 2 && strcmp("-d", argv[1]) == 0)
+ } else if(argc > 1 && !strcmp("-d", argv[1])) {
detach = 1;
- else if(argc != 1)
- die("usage: tabbed [-d] [-v]\n");
+ if(argc > 2) set_cmd(argc-2, argv+2);
+ } else if(argc > 1) {
+ set_cmd(argc-1, argv+1);
+ }
+ if(!cmd)
+ die("usage: tabbed [-d] [-v] command\n");
if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
fprintf(stderr, "warning: no locale support\n");
if(!(dpy = XOpenDisplay(NULL)))
signature.asc
Description: Digital signature
