]> git.lizzy.rs Git - bspwm.git/commitdiff
New setting: 'status_stdout'
authorBastien Dejean <nihilhill@gmail.com>
Mon, 17 Dec 2012 19:12:23 +0000 (20:12 +0100)
committerBastien Dejean <nihilhill@gmail.com>
Mon, 17 Dec 2012 19:12:23 +0000 (20:12 +0100)
README.md
bspwm.1
events.c
messages.c
settings.c
settings.h
tree.c
tree.h

index 21df5b4ca72ae237eefabe0d1d7d08b289d502c2..6879f6917d74320e3f2551c0fafbc313e41875c0 100644 (file)
--- a/README.md
+++ b/README.md
@@ -272,6 +272,9 @@ Colors are either [X color names](http://en.wikipedia.org/wiki/X11_color_names)
     adaptative_raise
         Prevent floating windows from being raised when they might cover other floating windows.
 
+    status_stdout
+        Output the status of monitors and desktops on stdout.
+
 ## Mouse Bindings
 
     button_modifier + left mouse button
diff --git a/bspwm.1 b/bspwm.1
index ffae3d646e1e1b39cf2a5bc58a823530ca1c1586..e38c47c85dcc7dc00a08489e9dc77c7827721bb7 100644 (file)
--- a/bspwm.1
+++ b/bspwm.1
@@ -311,6 +311,9 @@ Wether to focus the window under the mouse pointer.
 .TP
 .I adaptative_raise
 Prevent floating windows from being raised when they might cover other floating windows.
+.TP
+.I status_stdout
+Output the status of monitors and desktops on stdout.
 .SH MOUSE BINDINGS
 .TP
 .I button_modifier + left mouse button
index 27acba37fd2e90d6ff5753b97bb0278c91ce643c..361da7da136e74550265b3425910f98517ee7b23 100644 (file)
--- a/events.c
+++ b/events.c
@@ -192,6 +192,7 @@ void property_notify(xcb_generic_event_t *evt)
             return;
         if (xcb_icccm_get_wm_hints_reply(dpy, xcb_icccm_get_wm_hints(dpy, e->window), &hints, NULL) == 1) {
             loc.node->client->urgent = (hints.flags & XCB_ICCCM_WM_HINT_X_URGENCY);
+            put_status();
             if (loc.monitor->desk == loc.desktop)
                 arrange(loc.monitor, loc.desktop);
         }
index a897345be806f43c49b37b9a4d13f9e62f254e62..44da37c4fc1a20bdbbee7a8f076f178cb232a631 100644 (file)
@@ -82,11 +82,13 @@ void process_message(char *msg, char *rsp)
                 }
             }
         }
+        put_status();
     } else if (strcmp(cmd, "cycle_layout") == 0) {
         if (mon->desk->layout == LAYOUT_MONOCLE)
             mon->desk->layout = LAYOUT_TILED;
         else
             mon->desk->layout = LAYOUT_MONOCLE;
+        put_status();
     } else if (strcmp(cmd, "shift") == 0) {
         char *dir = strtok(NULL, TOK_SEP);
         if (dir != NULL) {
@@ -180,6 +182,7 @@ void process_message(char *msg, char *rsp)
                 char *new_name = strtok(NULL, TOK_SEP);
                 if (new_name != NULL) {
                     strncpy(m->name, new_name, sizeof(m->name));
+                    put_status();
                 }
             }
         }
@@ -192,6 +195,7 @@ void process_message(char *msg, char *rsp)
                 if (new_name != NULL) {
                     strncpy(loc.desktop->name, new_name, sizeof(loc.desktop->name));
                     ewmh_update_desktop_names();
+                    put_status();
                 }
             }
         }
@@ -412,6 +416,10 @@ void set_setting(char *name, char *value, char *rsp)
         bool b;
         if (parse_bool(value, &b))
             adaptative_raise = b;
+    } else if (strcmp(name, "status_stdout") == 0) {
+        bool b;
+        if (parse_bool(value, &b))
+            status_stdout = b;
     } else if (strcmp(name, "wm_name") == 0) {
         strncpy(wm_name, value, sizeof(wm_name));
         ewmh_update_wm_name();
@@ -499,6 +507,8 @@ void get_setting(char *name, char* rsp)
         snprintf(rsp, BUFSIZ, "%s", BOOLSTR(focus_follows_mouse));
     else if (strcmp(name, "adaptative_raise") == 0)
         snprintf(rsp, BUFSIZ, "%s", BOOLSTR(adaptative_raise));
+    else if (strcmp(name, "status_stdout") == 0)
+        snprintf(rsp, BUFSIZ, "%s", BOOLSTR(status_stdout));
     else if (strcmp(name, "wm_name") == 0)
         snprintf(rsp, BUFSIZ, "%s", wm_name);
     else if (strcmp(name, "button_modifier") == 0)
index 4fef401d6b555bfbb7496521585ab3313b6bb377..3a31829f45cd88a5b997157a801f2db1e5cb1f82 100644 (file)
@@ -70,4 +70,5 @@ void load_settings(void)
     gapless_monocle = GAPLESS_MONOCLE;
     focus_follows_mouse = FOCUS_FOLLOWS_MOUSE;
     adaptative_raise = ADAPTATIVE_RAISE;
+    status_stdout = STATUS_STDOUT;
 }
index 54d336c5482b8d51a3acd6139b8321d1523a07d6..19c921dd44f884effd0973df3501c8dae5eb17f5 100644 (file)
@@ -31,6 +31,7 @@
 #define GAPLESS_MONOCLE      false
 #define FOCUS_FOLLOWS_MOUSE  false
 #define ADAPTATIVE_RAISE     false
+#define STATUS_STDOUT        false
 
 char focused_border_color[MAXLEN];
 char active_border_color[MAXLEN];
@@ -65,6 +66,7 @@ bool borderless_monocle;
 bool gapless_monocle;
 bool focus_follows_mouse;
 bool adaptative_raise;
+bool status_stdout;
 
 char wm_name[MAXLEN];
 unsigned int button_modifier;
diff --git a/tree.c b/tree.c
index 43b17c259f155b1d12fc24fa71bc3165902cf890..e9e1fcd1972e651d2345c7d9a08b24cd57506d1e 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -233,6 +233,23 @@ void list_desktops(monitor_t *m, list_option_t opt, unsigned int depth, char *rs
     }
 }
 
+void put_status(void)
+{
+    if (!status_stdout)
+        return;
+    bool urgent = false;
+    for (monitor_t *m = mon_head; m != NULL; m = m->next) {
+        printf("%c%s:", (mon == m ? 'M' : 'm'), m->name);
+        for (desktop_t *d = m->desk_head; d != NULL; d = d->next, urgent = false) {
+            for (node_t *n = first_extrema(d->root); n != NULL && !urgent; n = next_leaf(n))
+                urgent |= n->client->urgent;
+            printf("%c%c%s:", (m->desk == d ? 'D' : (d->root != NULL ? 'd' : '_')), (urgent ? '!' : '_'), d->name);
+        }
+    }
+    printf("L%c:W%X\n", (mon->desk->layout == LAYOUT_TILED ? 'T' : 'M'), (mon->desk->focus == NULL ? 0 : mon->desk->focus->client->window));
+    fflush(stdout);
+}
+
 void arrange(monitor_t *m, desktop_t *d)
 {
     PRINTF("arrange %s%s%s\n", (num_monitors > 1 ? m->name : ""), (num_monitors > 1 ? " " : ""), d->name);
@@ -441,6 +458,7 @@ void focus_node(monitor_t *m, desktop_t *d, node_t *n, bool is_mapped)
     }
 
     ewmh_update_active_window();
+    put_status();
 }
 
 void update_current(void)
@@ -449,6 +467,7 @@ void update_current(void)
         ewmh_update_active_window();
     else
         focus_node(mon, mon->desk, mon->desk->focus, true);
+    put_status();
 }
 
 void unlink_node(desktop_t *d, node_t *n)
@@ -617,6 +636,7 @@ void select_monitor(monitor_t *m)
     mon = m;
 
     ewmh_update_current_desktop();
+    put_status();
 }
 
 void select_desktop(desktop_t *d)
@@ -645,6 +665,7 @@ void select_desktop(desktop_t *d)
 
     update_current();
     ewmh_update_current_desktop();
+    put_status();
 }
 
 void cycle_monitor(cycle_dir_t dir)
@@ -779,6 +800,7 @@ void add_desktop(monitor_t *m, char *name)
     num_desktops++;
     ewmh_update_number_of_desktops();
     ewmh_update_desktop_names();
+    put_status();
 }
 
 void add_monitor(xcb_rectangle_t *rect)
diff --git a/tree.h b/tree.h
index ee4cc3fd0911be69bb8f4322f89e4f77cbb1910d..9a164504a6a638b6dff2e27f8f6cb24ea6c789ad 100644 (file)
--- a/tree.h
+++ b/tree.h
@@ -24,6 +24,7 @@ void insert_node(monitor_t *, desktop_t *, node_t *);
 void dump_tree(desktop_t *, node_t *, char *, unsigned int);
 void list_desktops(monitor_t *, list_option_t, unsigned int, char *);
 void list_monitors(list_option_t, char *);
+void put_status(void);
 void focus_node(monitor_t *, desktop_t *, node_t *, bool);
 void update_current(void);
 void unlink_node(desktop_t *, node_t *);