summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2020-09-10 13:32:28 +0200
committerbakkeby <[email protected]>2020-09-10 13:32:28 +0200
commit8994f375e8ca8042996d752a385b8d1706526a25 (patch)
treed24c6af80be6c89bb2b04f61efe2753dc8b35f95 /patch
parentf4a6866e8c281bf9098d167fa6032e2eb19b87cd (diff)
downloaddwm-flexipatch-8994f375e8ca8042996d752a385b8d1706526a25.tar.gz
dwm-flexipatch-8994f375e8ca8042996d752a385b8d1706526a25.zip
anybar: initial commit
Diffstat (limited to 'patch')
-rw-r--r--patch/bar_anybar.c62
-rw-r--r--patch/bar_anybar.h4
-rw-r--r--patch/include.c3
-rw-r--r--patch/include.h3
4 files changed, 72 insertions, 0 deletions
diff --git a/patch/bar_anybar.c b/patch/bar_anybar.c
new file mode 100644
index 0000000..cc4b714
--- /dev/null
+++ b/patch/bar_anybar.c
@@ -0,0 +1,62 @@
+void
+managealtbar(Window win, XWindowAttributes *wa)
+{
+ Monitor *m;
+ if (!(m = recttomon(wa->x, wa->y, wa->width, wa->height)))
+ return;
+
+ m->bar->win = win;
+ m->bar->by = wa->y;
+ bh = m->bar->bh = wa->height;
+ updatebarpos(m);
+ arrange(m);
+ XSelectInput(dpy, win, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
+ XMoveResizeWindow(dpy, win, wa->x, wa->y, wa->width, wa->height);
+ XMapWindow(dpy, win);
+ XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
+ (unsigned char *) &win, 1);
+}
+
+void
+spawnbar()
+{
+ if (*altbarcmd)
+ system(altbarcmd);
+}
+
+void
+unmanagealtbar(Window w)
+{
+ Monitor *m = wintomon(w);
+
+ if (!m)
+ return;
+
+ m->bar->win = 0;
+ m->bar->by = 0;
+ m->bar->bh = 0;
+ updatebarpos(m);
+ arrange(m);
+}
+
+int
+wmclasscontains(Window win, const char *class, const char *name)
+{
+ XClassHint ch = { NULL, NULL };
+ int res = 1;
+
+ if (XGetClassHint(dpy, win, &ch)) {
+ if (ch.res_name && strstr(ch.res_name, name) == NULL)
+ res = 0;
+ if (ch.res_class && strstr(ch.res_class, class) == NULL)
+ res = 0;
+ } else
+ res = 0;
+
+ if (ch.res_class)
+ XFree(ch.res_class);
+ if (ch.res_name)
+ XFree(ch.res_name);
+
+ return res;
+} \ No newline at end of file
diff --git a/patch/bar_anybar.h b/patch/bar_anybar.h
new file mode 100644
index 0000000..99f439a
--- /dev/null
+++ b/patch/bar_anybar.h
@@ -0,0 +1,4 @@
+static void managealtbar(Window win, XWindowAttributes *wa);
+static void spawnbar();
+static void unmanagealtbar(Window w);
+static int wmclasscontains(Window win, const char *class, const char *name); \ No newline at end of file
diff --git a/patch/include.c b/patch/include.c
index 66eba15..50af31a 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -8,6 +8,9 @@
#if BAR_ALTERNATIVE_TAGS_PATCH
#include "bar_alternativetags.c"
#endif
+#if BAR_ANYBAR_PATCH
+#include "bar_anybar.c"
+#endif
#if BAR_DWMBLOCKS_PATCH && BAR_STATUSCMD_PATCH
#include "bar_dwmblocks.c"
#endif
diff --git a/patch/include.h b/patch/include.h
index 94b5a59..63a1387 100644
--- a/patch/include.h
+++ b/patch/include.h
@@ -8,6 +8,9 @@
#if BAR_ALTERNATIVE_TAGS_PATCH
#include "bar_alternativetags.h"
#endif
+#if BAR_ANYBAR_PATCH
+#include "bar_anybar.h"
+#endif
#if BAR_DWMBLOCKS_PATCH && BAR_STATUSCMD_PATCH
#include "bar_dwmblocks.h"
#endif