[hackers] [tabbed] Allowing a different position for the window id. Thanks David Galos! || Christoph Lohmann

From: <hg_AT_suckless.org>
Date: Thu, 8 Nov 2012 21:53:54 +0100 (CET)

changeset: 178:5fa9fa594867
user: Christoph Lohmann <20h_AT_r-36.net>
date: Thu Nov 08 21:48:51 2012 +0100
files: tabbed.1 tabbed.c
description:
Allowing a different position for the window id. Thanks David Galos!


diff -r 43eace0869b2 -r 5fa9fa594867 tabbed.1
--- a/tabbed.1 Thu Nov 08 21:40:58 2012 +0100
+++ b/tabbed.1 Thu Nov 08 21:48:51 2012 +0100
_AT_@ -9,6 +9,8 @@
 .RB [ \-v ]
 .RB [ \-n
 .IR name ]
+.RB [ \-r
+.IR narg ]
 .IR [ command ... ]
 .SH DESCRIPTION
 .B tabbed
_AT_@ -29,6 +31,13 @@
 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
_AT_@ -61,4 +70,18 @@
 $ 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 -r 43eace0869b2 -r 5fa9fa594867 tabbed.c
--- a/tabbed.c Thu Nov 08 21:40:58 2012 +0100
+++ b/tabbed.c Thu Nov 08 21:48:51 2012 +0100
_AT_@ -118,7 +118,7 @@
 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);
_AT_@ -766,14 +766,14 @@
 }
 
 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
_AT_@ -952,12 +952,12 @@
 
 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':
_AT_@ -966,6 +966,9 @@
         case 'n':
                 wmname = EARGF(usage());
                 break;
+ case 'r':
+ replace = atoi(EARGF(usage()));
+ break;
         case 's':
                 doinitspawn = False;
                 break;
_AT_@ -981,7 +984,7 @@
         if(argc < 1)
                 doinitspawn = False;
 
- setcmd(argc, argv);
+ setcmd(argc, argv, replace);
 
         if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
                 fprintf(stderr, "tabbed: no locale support\n");
Received on Thu Nov 08 2012 - 21:53:54 CET

This archive was generated by hypermail 2.3.0 : Thu Nov 08 2012 - 22:00:10 CET