commit 380c783155ea9c8af5c3c7e65bfb3b8c12c5e6ff
parent 3f0067b1c775a7f0ade805e10546272f8ce01dd3
Author: Christoph Lohmann <20h@r-36.net>
Date: Thu, 8 Nov 2012 21:48:51 +0100
Allowing a different position for the window id. Thanks David Galos!
Diffstat:
2 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/tabbed.1 b/tabbed.1
@@ -9,6 +9,8 @@ tabbed \- generic tabbed interface
.RB [ \-v ]
.RB [ \-n
.IR name ]
+.RB [ \-r
+.IR narg ]
.IR [ command ... ]
.SH DESCRIPTION
.B tabbed
@@ -29,6 +31,13 @@ will print the usage of tabbed.
will set the WM_CLASS attribute to
.I name.
.TP
+.BI \-r " narg"
+will replace the
+.I narg
+th argument in
+.I command
+with the window id, rather than appending it to the end.
+.TP
.B \-s
will disable automatic spawning of the command.
.TP
@@ -61,4 +70,18 @@ $ tabbed urxvt -embed
$ tabbed xterm -into
.TP
$ $(tabbed -d >/tmp/tabbed.xid); urxvt -embed $(</tmp/tabbed.xid);
+.TP
+$ tabbed -r 2 st -w '' -e tmux
+.SH CUSTOMIZATION
+.B tabbed
+can be customized by creating a custom config.h and (re)compiling the source
+code. This keeps it fast, secure and simple.
+.SH AUTHORS
+See the LICENSE file for the authors.
+.SH LICENSE
+See the LICENSE file for the terms of redistribution.
+.SH SEE ALSO
+.BR st (1)
+.SH BUGS
+Please report them.
diff --git a/tabbed.c b/tabbed.c
@@ -118,7 +118,7 @@ static void rotate(const Arg *arg);
static void run(void);
static void sendxembed(Client *c, long msg, long detail, long d1, long d2);
static void setup(void);
-static void setcmd(int argc, char *argv[]);
+static void setcmd(int argc, char *argv[], int);
static void sigchld(int unused);
static void spawn(const Arg *arg);
static int textnw(const char *text, unsigned int len);
@@ -766,14 +766,14 @@ sendxembed(Client *c, long msg, long detail, long d1, long d2) {
}
void
-setcmd(int argc, char *argv[]) {
+setcmd(int argc, char *argv[], int replace) {
int i;
cmd = emallocz((argc+2) * sizeof(*cmd));
for(i = 0; i < argc; i++)
cmd[i] = argv[i];
- cmd[argc] = winid;
- cmd[argc+1] = NULL;
+ cmd[(replace > 0)? replace : argc] = winid;
+ cmd[argc + !(replace > 0)] = NULL;
}
void
@@ -952,12 +952,12 @@ char *argv0;
void
usage(void) {
- die("usage: %s [-dhsv] [-n name] command...\n", argv0);
+ die("usage: %s [-dhsv] [-n name] [-r narg] command...\n", argv0);
}
int
main(int argc, char *argv[]) {
- int detach = 0;
+ int detach = 0, replace = 0;
ARGBEGIN {
case 'd':
@@ -966,6 +966,9 @@ main(int argc, char *argv[]) {
case 'n':
wmname = EARGF(usage());
break;
+ case 'r':
+ replace = atoi(EARGF(usage()));
+ break;
case 's':
doinitspawn = False;
break;
@@ -981,7 +984,7 @@ main(int argc, char *argv[]) {
if(argc < 1)
doinitspawn = False;
- setcmd(argc, argv);
+ setcmd(argc, argv, replace);
if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
fprintf(stderr, "tabbed: no locale support\n");