~ruther/dwl

3868217466a2264f2645b5f63c74d0ae1a28acd6 — David Donahue 4 years ago a4c0b91
Added interface to output information about tags, the currently selected monitor, and the focused client to a file for use by a status bar
1 files changed, 36 insertions(+), 0 deletions(-)

M dwl.c
M dwl.c => dwl.c +36 -0
@@ 280,6 280,7 @@ static void setmon(Client *c, Monitor *m, unsigned int newtags);
static void setup(void);
static void sigchld(int unused);
static void spawn(const Arg *arg);
static void statusbar(void);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);


@@ 1116,6 1117,7 @@ focusclient(Client *c, int lift)
		wl_list_insert(&fstack, &c->flink);
		selmon = c->mon;
	}
    statusbar();

	/* Deactivate old client if focus is changing */
	if (old && (!c || client_surface(c) != old)) {


@@ 1914,6 1916,7 @@ setlayout(const Arg *arg)
		selmon->lt[selmon->sellt] = (Layout *)arg->v;
	/* TODO change layout symbol? */
	arrange(selmon);
    statusbar();
}

/* arg > 1.0 will set mfact absolutely */


@@ 2156,6 2159,39 @@ spawn(const Arg *arg)
}

void
statusbar(void)
{
	Monitor *m = NULL;
	Client *c = NULL;
	FILE *taginfo;
	const char *title;
	char fname[30]="";
	unsigned int activetags;

	//Add WAYLAND_DISPLAY to filename so each session has a predictable file
	snprintf(fname, 30, "/tmp/dwltags-%s", getenv("WAYLAND_DISPLAY"));

	if (!(taginfo = fopen(fname, "w")))
		return;

	wl_list_for_each(m, &mons, link) {
		activetags=0;
		wl_list_for_each(c, &clients, link) {
			if (c->mon == m)
				activetags |= c->tags;
		}
		if (focustop(m))
			fprintf(taginfo, "%s\n", client_get_title(focustop(m)));
		else
			fprintf(taginfo, "\n");

		fprintf(taginfo, "%u %u %u %s\n", m == selmon,
				activetags, m->tagset[m->seltags], selmon->lt[selmon->sellt]->symbol);
	}
	fclose (taginfo);
}

void
tag(const Arg *arg)
{
	Client *sel = selclient();

Do not follow this link