Adding the -c option to close on last client close. - tabbed - tab interface fo… | |
git clone git://git.suckless.org/tabbed | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 39594f1935e8cd8f27c55b4716b8194a99e4b65d | |
parent 34a643f79c3c1dc2577990ce0c8d69703f6738b4 | |
Author: Christoph Lohmann <[email protected]> | |
Date: Tue, 25 Dec 2012 16:50:32 +0100 | |
Adding the -c option to close on last client close. | |
Thanks for the suggestion by Kyle Kramer! | |
Diffstat: | |
M tabbed.1 | 6 +++++- | |
M tabbed.c | 26 ++++++++++++++++++-------- | |
2 files changed, 23 insertions(+), 9 deletions(-) | |
--- | |
diff --git a/tabbed.1 b/tabbed.1 | |
@@ -3,6 +3,7 @@ | |
tabbed \- generic tabbed interface | |
.SH SYNOPSIS | |
.B tabbed | |
+.RB [ \-c ] | |
.RB [ \-d ] | |
.RB [ \-h ] | |
.RB [ \-s ] | |
@@ -21,12 +22,15 @@ disabled by providing the -s parameter. If no command is pr… | |
tabbed will just print its xid and run no command. | |
.SH OPTIONS | |
.TP | |
+.B \-c | |
+close tabbed when the last tab is closed. Mutually exclusive with -f. | |
+.TP | |
.B \-d | |
detaches tabbed from the terminal and prints its XID to stdout. | |
.TP | |
.B \-f | |
fill up tabbed again by spawning the provided command, when the last tab is | |
-closed. | |
+closed. Mutually exclusive with -c. | |
.TP | |
.B \-h | |
will print the usage of tabbed. | |
diff --git a/tabbed.c b/tabbed.c | |
@@ -147,7 +147,8 @@ static void (*handler[LASTEvent]) (const XEvent *) = { | |
}; | |
static int bh, wx, wy, ww, wh; | |
static unsigned int numlockmask = 0; | |
-static Bool running = True, nextfocus, doinitspawn = True, fillagain = False; | |
+static Bool running = True, nextfocus, doinitspawn = True, | |
+ fillagain = False, closelastclient = False; | |
static Display *dpy; | |
static DC dc; | |
static Atom wmatom[WMLast]; | |
@@ -980,8 +981,13 @@ unmanage(int c) { | |
focus(sel); | |
} | |
- if(nclients == 0 && fillagain) | |
- spawn(NULL); | |
+ if(nclients == 0) { | |
+ if (closelastclient) { | |
+ running = False; | |
+ } else if (fillagain && running) { | |
+ spawn(NULL); | |
+ } | |
+ } | |
drawbar(); | |
XSync(dpy, False); | |
@@ -1057,14 +1063,18 @@ usage(void) { | |
int | |
main(int argc, char *argv[]) { | |
- int detach = 0, replace = 0; | |
+ Bool detach = False; | |
+ int replace = 0; | |
ARGBEGIN { | |
+ case 'c': | |
+ closelastclient = True; | |
+ fillagain = False; | |
case 'd': | |
- detach = 1; | |
+ detach = True; | |
break; | |
case 'f': | |
- fillagain = 1; | |
+ fillagain = True; | |
break; | |
case 'n': | |
wmname = EARGF(usage()); | |
@@ -1101,9 +1111,9 @@ main(int argc, char *argv[]) { | |
fflush(NULL); | |
if(detach) { | |
- if(fork() == 0) | |
+ if(fork() == 0) { | |
fclose(stdout); | |
- else { | |
+ } else { | |
if(dpy) | |
close(ConnectionNumber(dpy)); | |
return EXIT_SUCCESS; |