[wiki] [sites] [dwm] Clickable left-hand side statusbutton. || Christopher Drelich

From: <git_AT_suckless.org>
Date: Fri, 25 May 2018 02:32:06 +0200

commit 38e585363d3c2ba9d2e07cc0e0d780f5ff11e33c
Author: Christopher Drelich <cd_AT_cdrakka.com>
Date: Thu May 24 20:31:33 2018 -0400

    [dwm] Clickable left-hand side statusbutton.

diff --git a/dwm.suckless.org/patches/statusbutton/dwm-statusbutton-20180524-c8e9479.diff b/dwm.suckless.org/patches/statusbutton/dwm-statusbutton-20180524-c8e9479.diff
new file mode 100644
index 00000000..6dc96d73
--- /dev/null
+++ b/dwm.suckless.org/patches/statusbutton/dwm-statusbutton-20180524-c8e9479.diff
_AT_@ -0,0 +1,92 @@
+From 63515eaf23d3f32f12d159c5e84af09f3a2d3323 Mon Sep 17 00:00:00 2001
+From: Christopher Drelich <cd_AT_cdrakka.com>
+Date: Thu, 24 May 2018 20:26:42 -0400
+Subject: [PATCH] Added left-hand side statusbar button.
+
+---
+ config.def.h | 2 ++
+ dwm.c | 34 +++++++++++++++++++++-------------
+ 2 files changed, 23 insertions(+), 13 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index a9ac303..63ff917 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -5,6 +5,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
+ static const unsigned int snap = 32; /* snap pixel */
+ static const int showbar = 1; /* 0 means no bar */
+ static const int topbar = 1; /* 0 means bottom bar */
++static const char buttonbar[] = "<O>";
+ static const char *fonts[] = { "monospace:size=10" };
+ static const char dmenufont[] = "monospace:size=10";
+ static const char col_gray1[] = "#222222";
+_AT_@ -100,6 +101,7 @@ static Key keys[] = {
+ /* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
+ static Button buttons[] = {
+ /* click event mask button function argument */
++ { ClkButton, 0, Button1, spawn, {.v = dmenucmd } },
+ { ClkLtSymbol, 0, Button1, setlayout, {0} },
+ { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
+ { ClkWinTitle, 0, Button2, zoom, {0} },
+diff --git a/dwm.c b/dwm.c
+index bb95e26..689cb01 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -64,7 +64,7 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
+ NetWMFullscreen, NetActiveWindow, NetWMWindowType,
+ NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
+ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
+-enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
++enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkButton, ClkWinTitle,
+ ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
+
+ typedef union {
+_AT_@ -431,18 +431,23 @@ buttonpress(XEvent *e)
+ }
+ if (ev->window == selmon->barwin) {
+ i = x = 0;
+- do
+- x += TEXTW(tags[i]);
+- while (ev->x >= x && ++i < LENGTH(tags));
+- if (i < LENGTH(tags)) {
+- click = ClkTagBar;
+- arg.ui = 1 << i;
+- } else if (ev->x < x + blw)
+- click = ClkLtSymbol;
+- else if (ev->x > selmon->ww - TEXTW(stext))
+- click = ClkStatusText;
+- else
+- click = ClkWinTitle;
++ x += TEXTW(buttonbar);
++ if(ev->x < x) {
++ click = ClkButton;
++ } else {
++ do
++ x += TEXTW(tags[i]);
++ while (ev->x >= x && ++i < LENGTH(tags));
++ if (i < LENGTH(tags)) {
++ click = ClkTagBar;
++ arg.ui = 1 << i;
++ } else if (ev->x < x + blw)
++ click = ClkLtSymbol;
++ else if (ev->x > selmon->ww - TEXTW(stext))
++ click = ClkStatusText;
++ else
++ click = ClkWinTitle;
++ }
+ } else if ((c = wintoclient(ev->window))) {
+ focus(c);
+ restack(selmon);
+_AT_@ -714,6 +719,9 @@ drawbar(Monitor *m)
+ urg |= c->tags;
+ }
+ x = 0;
++ w = blw = TEXTW(buttonbar);
++ drw_setscheme(drw, scheme[SchemeNorm]);
++ x = drw_text(drw, x, 0, w, bh, lrpad / 2, buttonbar, 0);
+ for (i = 0; i < LENGTH(tags); i++) {
+ w = TEXTW(tags[i]);
+ drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
+--
+2.7.4
+
diff --git a/dwm.suckless.org/patches/statusbutton/index.md b/dwm.suckless.org/patches/statusbutton/index.md
new file mode 100644
index 00000000..e0fd7321
--- /dev/null
+++ b/dwm.suckless.org/patches/statusbutton/index.md
_AT_@ -0,0 +1,19 @@
+# statusbutton
+
+## Description
+
+Adds a clickable button to the left hand side of the statusbar.
+
+The appearance of this button can be configured by modifying buttonbar in config.def.h
+
+ClkButton is added as the target for clicking this button.
+
+It has been configured for now in config.def.h to spawn dmenucmd when clicked with Button1.
+
+## Download
+
+ * [dwm-statusbutton-20180524-c8e9479.diff](dwm-statusbutton-20180524-c8e9479.diff) (24.05.2018)
+
+## Author
+
+ * cd
Received on Fri May 25 2018 - 02:32:06 CEST

This archive was generated by hypermail 2.3.0 : Fri May 25 2018 - 02:36:26 CEST