summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Donahue <david.donahue2996@gmail.com>2021-02-07 00:31:01 -0600
committerDavid Donahue <david.donahue2996@gmail.com>2021-02-07 00:31:01 -0600
commit3868217466a2264f2645b5f63c74d0ae1a28acd6 (patch)
treea704fbfc296e93245314732cfac6809e5a41afd6
parenta4c0b914f09b40e27df535dc20913d0fddcc2c62 (diff)
Added interface to output information about tags, the currently selected monitor, and the focused client to a file for use by a status bar
-rw-r--r--dwl.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/dwl.c b/dwl.c
index 5b5e35e..8e43829 100644
--- a/dwl.c
+++ b/dwl.c
@@ -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();