aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2012-12-25 16:50:32 +0100
committerChristoph Lohmann <20h@r-36.net>2012-12-25 16:50:32 +0100
commit39594f1935e8cd8f27c55b4716b8194a99e4b65d (patch)
tree4ef75915e0eeccc74c197c47ef00aa178ab1f474
parent34a643f79c3c1dc2577990ce0c8d69703f6738b4 (diff)
Adding the -c option to close on last client close.
Thanks for the suggestion by Kyle Kramer!
-rw-r--r--tabbed.16
-rw-r--r--tabbed.c26
2 files changed, 23 insertions, 9 deletions
diff --git a/tabbed.1 b/tabbed.1
index b2d760a..48b3182 100644
--- 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 provided
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
index 2126bad..13efee4 100644
--- 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;