]> git.lizzy.rs Git - bspwm.git/commitdiff
New message: 'remove_rule'
authorBastien Dejean <nihilhill@gmail.com>
Tue, 25 Dec 2012 18:28:24 +0000 (19:28 +0100)
committerBastien Dejean <nihilhill@gmail.com>
Tue, 25 Dec 2012 18:28:24 +0000 (19:28 +0100)
README.md
bspwm.1
messages.c
rules.c
rules.h

index 9e8683b3f62b594d2809dc1ce634e7db39f48fed..d5fa94b604e1d29c797524064387855a120605f2 100644 (file)
--- a/README.md
+++ b/README.md
@@ -200,6 +200,9 @@ The following messages are handled:
     rule PATTERN [DESKTOP_NAME] [floating]
         Create a new rule (PATTERN must match the class or instance name).
 
+    remove_rule UID ...
+        Remove the rules with the given UIDs.
+
     adopt_orphans
         Manage all the unmanaged windows remaining from a previous session.
 
diff --git a/bspwm.1 b/bspwm.1
index c2bc7a8f486413b9d648b1d393b9dcabc2422ef4..9b8b9e549bf8d290e96c7851e5f414fdb1128b86 100644 (file)
--- a/bspwm.1
+++ b/bspwm.1
@@ -220,9 +220,12 @@ Cycle the layout of the current desktop.
 .BI rotate " clockwise|counter_clockwise|full_cycle"
 Rotate the tree of the current desktop.
 .TP
-.BI rule " PATTERN [DESKTOP_NAME] [floating] "
+.BI rule " PATTERN [DESKTOP_NAME] [floating]"
 Create a new rule (PATTERN must match the class or instance name).
 .TP
+.BI remove_rule " UID ..."
+Remove the rules with the given UIDs.
+.TP
 .BI adopt_orphans
 Manage all the unmanaged windows remaining from a previous session.
 .TP
index feff8f66a9988026a77988ddeac5bb5e7ebcab2c..52a895e32c1debb1e28cbc7c3ff6f5761bb10c0c 100644 (file)
@@ -311,6 +311,13 @@ void process_message(char *msg, char *rsp)
             add_rule(rule);
         }
         return;
+    } else if (strcmp(cmd, "remove_rule") == 0) {
+        char *arg;
+        unsigned int uid;
+        while ((arg = strtok(NULL, TOK_SEP)) != NULL)
+            if (sscanf(arg, "%X", &uid) > 0)
+                remove_rule(uid);
+        return;
     } else if (strcmp(cmd, "alternate") == 0) {
         focus_node(mon, mon->desk, mon->desk->last_focus, true);
         return;
diff --git a/rules.c b/rules.c
index 3b5e22fc219fdc5be092b4ac7395565ac4d14cbc..a943d078b0db41d3f2f25866f83165cd7287d6d1 100644 (file)
--- a/rules.c
+++ b/rules.c
@@ -18,6 +18,31 @@ void add_rule(rule_t *r)
     }
 }
 
+void remove_rule(unsigned int uid)
+{
+    rule_t *r = find_rule(uid);
+    if (r != NULL) {
+        rule_t *prev = r->prev;
+        rule_t *next = r->next;
+        if (prev != NULL)
+            prev->next = next;
+        if (next != NULL)
+            next->prev = prev;
+        if (r == rule_head)
+            rule_head = next;
+        if (r == rule_tail)
+            rule_tail = prev;
+    }
+}
+
+rule_t *find_rule(unsigned int uid)
+{
+    for (rule_t *r = rule_head; r != NULL; r = r->next)
+        if (r->uid == uid)
+            return r;
+    return NULL;
+}
+
 bool is_match(rule_t *r, xcb_window_t win)
 {
     xcb_icccm_get_wm_class_reply_t reply; 
diff --git a/rules.h b/rules.h
index 27b718469718c966142c2602922dccea0bb03964..41a2fc6e4dd9917ac0f23d43f942db088422fdaa 100644 (file)
--- a/rules.h
+++ b/rules.h
@@ -2,6 +2,8 @@
 #define _RULES_H
 
 void add_rule(rule_t *);
+void remove_rule(unsigned int);
+rule_t *find_rule(unsigned int);
 bool is_match(rule_t *, xcb_window_t);
 void handle_rules(xcb_window_t, monitor_t **, desktop_t **, bool *, bool *, bool *, bool *, bool *);
 void list_rules(char *);