summaryrefslogtreecommitdiffstats
path: root/tabbed.c
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 /tabbed.c
parent34a643f79c3c1dc2577990ce0c8d69703f6738b4 (diff)
downloadtabbed-39594f1935e8cd8f27c55b4716b8194a99e4b65d.tar.gz
Adding the -c option to close on last client close.
Thanks for the suggestion by Kyle Kramer!
Diffstat (limited to 'tabbed.c')
-rw-r--r--tabbed.c26
1 files changed, 18 insertions, 8 deletions
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;